Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. vgg = keras.applications.VGG16(weights='imagenet', include_top=True)
  2. vgg.summary()
  3.  
  4. inp = vgg.input
  5. new_classification_layer = Dense(num_classes, activation='softmax')
  6. out = new_classification_layer(vgg.layers[-2].output)
  7. model_new = Model(inp, out)
  8.  
  9. for l, layer in enumerate(model_new.layers[:-1]):
  10. layer.trainable = False
  11.  
  12. for l, layer in enumerate(model_new.layers[-1:]):
  13. layer.trainable = True
  14.  
  15. model_new.compile(loss='categorical_crossentropy',
  16. optimizer='adam',
  17. metrics=['accuracy'])
  18.  
  19. model_new.summary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement