擅长:python、mysql、java
<p>从PyTorch教程<a href="https://pytorch.org/tutorials/beginner/finetuning_torchvision_models_tutorial.html#Resnet" rel="nofollow noreferrer">"Finetuning TorchVision Models"</a>:</p>
<blockquote>
<p>Torchvision offers eight versions of VGG with various lengths and some that have batch normalizations layers. Here we use VGG-11 with batch normalization. The output layer is similar to Alexnet, i.e.</p>
<pre class="lang-py prettyprint-override"><code>(classifier): Sequential(
...
(6): Linear(in_features=4096, out_features=1000, bias=True)
)
</code></pre>
<p>Therefore, we use the same technique to modify the output layer</p>
<pre class="lang-py prettyprint-override"><code>model.classifier[6] = nn.Linear(4096,num_classes)
</code></pre>
</blockquote>