Created
August 20, 2017 15:26
-
-
Save gutomcosta/05a249c9d130fdb041f382a0eaf0e2e6 to your computer and use it in GitHub Desktop.
CNN using VGG19 architecture
This file contains hidden or 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
### TODO: Define your architecture. | |
from keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D | |
from keras.layers import Dropout, Flatten, Dense | |
from keras.models import Sequential | |
vgg19_model = Sequential() | |
vgg19_model.add(GlobalAveragePooling2D(input_shape=train_vgg19.shape[1:])) | |
vgg19_model.add(Dense(512, activation='relu')) | |
vgg19_model.add(Dropout(0.5)) | |
vgg19_model.add(Dense(512, activation='relu')) | |
vgg19_model.add(Dense(133, activation='softmax')) | |
vgg19_model.summary() | |
### TODO: Train the model. | |
checkpointer = ModelCheckpoint(filepath='saved_models/weights.best.VGG19.hdf5', | |
verbose=1, save_best_only=True) | |
vgg19_model.fit(train_vgg19, train_targets, | |
validation_data=(valid_vgg19, valid_targets),validation_split=0.2, | |
epochs=20, batch_size=120, callbacks=[checkpointer], verbose=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment