VGg implementation in Python modifies the last FC layer


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)

The last FC layer of the VGg implementation modification in Python is all the content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developeppaer more.

Recommended Today

Centos7 reset root password (detailed version)

  The root password is modified as follows: Step 1: press the “e” key when the following interface appears     Step 2: after pressing the “e” key in step 1, the following interface will appear. Press the ↓ key all the way to the bottom to find “lang = zh”_ CN.UTF -8 “, add” […]