神剑山庄资源网 Design By www.hcban.com

https://discuss.pytorch.org/t/how-to-modify-the-final-fc-layer-based-on-the-torch-model/766/12

That's because vgg19 doesn't have a fc member variable. Instead, it has a

 (classifier): Sequential (
 (0): Dropout (p = 0.5)
 (1): Linear (25088 -> 4096)
 (2): ReLU (inplace)
 (3): Dropout (p = 0.5)
 (4): Linear (4096 -> 4096)
 (5): ReLU (inplace)
 (6): Linear (4096 -> 100)
 )

To replace the last linear layer, a temporary solution would be

vgg19.classifier._modules['6'] = nn.Linear(4096, 8)

以上这篇Pytorch中的VGG实现修改最后一层FC就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
Pytorch,VGG,FC

神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网 免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com

评论“Pytorch中的VGG实现修改最后一层FC”

暂无Pytorch中的VGG实现修改最后一层FC的评论...