Skip to content

Instantly share code, notes, and snippets.

@agnesmm

agnesmm/a2g2.py Secret

Created September 17, 2017 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agnesmm/b9848790a812a358effb6c83445435be to your computer and use it in GitHub Desktop.
Save agnesmm/b9848790a812a358effb6c83445435be to your computer and use it in GitHub Desktop.
initial_model = VGG16(weights="imagenet", include_top=True)
x = Dense(batches.nb_class, activation='softmax')(initial_model.layers[-2].output)
model = Model(initial_model.input, x)
# we freeze the other layers
for layer in initial_model.layers: layer.trainable=False
opt = Adam(lr=0.001)
model.compile(optimizer=opt,
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit_generator(batches, samples_per_epoch=batches.nb_sample,
nb_epoch=3, validation_data=valid_batches,
nb_val_samples=valid_batches.nb_sample)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment