Pytorch中的VGG實現修改最后一層FC
更新時間:2020年01月15日 08:36:22 作者:ForABiggerWorld
今天小編就為大家分享一篇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)
以上這篇Pytorch中的VGG實現修改最后一層FC就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:

