Skip to content

Instantly share code, notes, and snippets.

@agnesmm agnesmm/a2g2.py Secret
Created Sep 17, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.