欢迎来到代码驿站!

Python代码

当前位置:首页 > 软件编程 > Python代码

Pytorch中的VGG实现修改最后一层FC

时间:2021-06-26 08:45:44|栏目:Python代码|点击:

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)

上一篇:Python数据正态性检验实现过程

栏    目:Python代码

下一篇:python实现的DES加密算法和3DES加密算法实例

本文标题:Pytorch中的VGG实现修改最后一层FC

本文地址:http://www.codeinn.net/misctech/148184.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有