Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vgg = keras.applications.VGG16(weights='imagenet', include_top=True)
- vgg.summary()
- inp = vgg.input
- new_classification_layer = Dense(num_classes, activation='softmax')
- out = new_classification_layer(vgg.layers[-2].output)
- model_new = Model(inp, out)
- for l, layer in enumerate(model_new.layers[:-1]):
- layer.trainable = False
- for l, layer in enumerate(model_new.layers[-1:]):
- layer.trainable = True
- model_new.compile(loss='categorical_crossentropy',
- optimizer='adam',
- metrics=['accuracy'])
- model_new.summary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement