[英]How to remove the last layer of pretrained model in tensorflow
I want to remove the last layer of sports1m_finetuning_ucf101.model in C3D tensorflow ( https://github.com/hx173149/C3D-tensorflow ) and add my own classifier layer for my dataset which has different number of labels than the model. 我想删除C3D tensorflow( https://github.com/hx173149/C3D-tensorflow )中最后一层sports1m_finetuning_ucf101.model,并为我的数据集添加我自己的分类器层,该分类器的标签数与模型数不同。 I know in Keras i can use the pop method but here I don't know how to load the model in tensorflow and remove the last layer.
我知道在Keras中我可以使用pop方法,但是在这里我不知道如何在tensorflow中加载模型并删除最后一层。 Is there anyone to tell me how I can do it?
有没有人告诉我我该怎么做?
In tensorflow
editing model is not recommended. 在
tensorflow
中不建议使用模型。 What you can probably do is that you can set the output based on the layer name. 您可能可以做的是可以基于图层名称设置输出。
for layer in model.layers:
if layer.name == desired_layer_name:
output = layer.output
break
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.