Created
March 20, 2017 17:49
-
-
Save anonymous/a53ea755963ee600f62318fde7ff0cf5 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
from keras.applications.vgg16 import VGG16 | |
from keras.layers.core import Dense | |
from keras.layers.convolutional import Convolution2D, MaxPooling2D, ZeroPadding2D | |
from keras.layers.pooling import GlobalAveragePooling2D | |
from keras.optimizers import SGD, RMSprop, Adam | |
# Roughly the code I had writted | |
base_model = VGG16(weights='imagenet') | |
for layer im base_model.layers: | |
layer.trainable = False | |
# Grab the second-to-last layer (to bypass the built-in predictions layer) | |
build_off = model.get_layer('fc2') | |
predictions = Dense(2, activation='softmax')(build_off.output) | |
model = Model(base_model.input, predictions) | |
model.compile(optimizer=Adam(lr=0.001), loss='categorical_crossentropy', metrics=['accuracy']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment