网络编程
位置:首页>> 网络编程>> Python编程>> Pytorch中的VGG实现修改最后一层FC

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

作者:ForABiggerWorld  发布时间:2023-03-08 07:08:48 

标签:Pytorch,VGG,FC

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)

来源:https://blog.csdn.net/zjucor/article/details/83713356

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com