-
-
Save agnesmm/b9848790a812a358effb6c83445435be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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