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

前端 未结 2 688
我在风中等你
我在风中等你 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:13

    Working off @Koul answer.

    I believe you don't need to use the pop method. Instead just pass the layer before the output layer as the argument for the Model method's output parameter:

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

提交回复
热议问题