I want to remove the last layer of 'faster_rcnn_nas_lowproposals_coco' model which downloaded from https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md. I know I in Keras we can use model.layers.pop() to remove the last layer.
But I searched in the Internet and there are no equivalent function in tensorflow. If there are no equivalent function in tensorflow, are there anyone can tell me how to load trained Model zoo by Keras?
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[-2].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. So, for loading the model without the last layer, x should be equal to -2.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With