Removing layers from a pretrained keras model gives the same output as original model

前端 未结 2 685
我在风中等你
我在风中等你 2021-02-14 02:35

During some feature extraction experiments, I noticed that the \'model.pop()\' functionality is not working as expected. For a pretrained model like vgg16, after using \'model.p

2条回答
  •  青春惊慌失措
    2021-02-14 03:14

    Found the answer here : https://github.com/keras-team/keras/issues/2371#issuecomment-308604552

    from keras.models import Model
    
    model.layers.pop()
    model2 = Model(model.input, model.layers[-1].output)
    model2.summary()
    

    model2 behaves correctly.

提交回复
热议问题