title: How to use the Inception model for transfer learning in PyTorch?
body: <p>I have created a PyTorch <code>torchvision</code> model for transfer learning, using the pre-built <em>ResNet50</em> base model, like this:</p>
  <pre class="lang-py prettyprint-override"><code>        # Create base model from torchvision.models
          model = resnet50(pretrained=True)
          num_features = model.fc.in_features
  
          # Define the network head and attach it to the model
          model_head = nn.Sequential(
              nn.Linear(num_features, 512),
              nn.ReLU(),
              nn.Dropout(0.25),
              nn.Linear(512, 256),
              nn.ReLU(),
              nn.Dropout(0.5),
              nn.Linear(256, num_classes),
          )
          model.fc = model_head
  </code></pre>
  <p>Now I wanted to use the <em>Ineception v3</em> model instead as base, so I switched from <code>resnet50()</code> above to <code>inception_v3()</code>, the rest stayed as is. However, during training I get the following error:</p>
  <blockquote>
  <p>TypeError: cross_entropy_loss(): argument 'input' (position 1) must be Tensor, not InceptionOutputs</p>
  </blockquote>
  <p>So how can one use the <em>Inception v3</em> model from <code>torchvision.models</code> as base model for transfer learning?</p>