Last active
December 15, 2018 22:30
-
-
Save maltseasy/163b003b5ca8c617395370be6d228eba 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
# Create a MobileNet model | |
mobile = keras.applications.mobilenet.MobileNet() | |
# Modify the model | |
# Choose the 6th layer from the last | |
x = mobile.layers[-6].output | |
# Add a dropout and dense layer for predictions | |
x = Dropout(0.25)(x) | |
predictions = Dense(7, activation='softmax')(x) | |
# Create a new model with the new outputs | |
model = Model(inputs=mobile.input, outputs=predictions) | |
# Prevent everything except the last 23 layers from being trained | |
for layer in model.layers[:-23]: | |
layer.trainable = False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment