You don't need to "pop" a layer, you just have to not load it:
For the example of Mobilenet (but put your downloaded model here) :
model = mobilenet.MobileNet()
x = model.layers[-1].output
The first line load the entire model, the second load the outputs of the before the last layer.
You can change layer[-x]
with x
being the outputs of the layer you want.
Then it's possible to use it like this :
x = Dense(256)(x)
predictions = Dense(15, activation = "softmax")(x)
model = Model(inputs = model.input, outputs = predictions)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…