Error in training inception-v3

username: PTA
cooked: <p>I have a model that was written using models from torchvision and I wanna test the performance with inception-v3. However, with the same model structure and imput images (size 224 x 224), I got the following error.</p>
<pre><code>RuntimeError: Calculated padded input size per channel: (3 x 3). Kernel size: (5 x 5). Kernel size can't be greater than actual input size at /pytorch/aten/src/THNN/generic/SpatialConvolutionMM.c:50
</code></pre>
<p>Any thoughts on how to fix this? Thanks!</p>

username: ptrblck
cooked: <p>Inception-v3 needs an input shape of <code>[batch_size, 3, 299, 299]</code> instead of <code>[..., 224, 224]</code>.<br>
You could up-/resample your images to the needed size and try it again.</p>

username: PTA
cooked: <p>Thanks! Any idea on why we designed Inception-v3 with 300 x 300 images while others normally with 224 x 224?</p>

username: ptrblck
cooked: <p>I assume Szegedy et al. got better results increasing the resolution for the variants of the Inception model.<br>
As far as I remember they used <code>224</code> in their <a href="https://arxiv.org/pdf/1409.4842.pdf">first version</a> and switched to <code>299</code> in their <a href="https://arxiv.org/pdf/1512.00567v3.pdf">Rethinking the Inception Architecture paper</a>.</p>

username: mathematics
cooked: <p>Hi ,<br>
I have got another error saying<br>
<code>AttributeError: 'InceptionOutputs' object has no attribute 'log_softmax'</code><br>
In incpetion_v3 pretrained model. Help!! :</p>

username: ptrblck
cooked: <p><code>InceptionOutputs</code> contains the <code>.logits</code> and <code>aux_logits</code> attribute, so you would need to index one of these tensors to call <code>.log_softmax</code> on it.</p>

username: mathematics
cooked: <p>How , I have tried to make it false</p>
<pre><code class="lang-auto">for name, param in model_transfer.named_parameters():

  if(name != 'fc.weight'):

    param.requires_grad = False

  param.aux_logits = False

  Param.logits = False
</code></pre>
<p>return same error, even used Nll loss got error<br>
<code>AttributeError: 'InceptionOutputs' object has no attribute 'dim'</code></p>
<p>How can i make would  <code> index one of these tensors to call</code></p>

username: ptrblck
cooked: <p><code>.logits</code> is an attribute of the output:</p>
<pre><code class="lang-python">out = model(torch.randn(2, 3, 299, 299))
out.logits.log_softmax(1)
</code></pre>
<p>If you don’t want to use the <code>aux_logits</code>, then set <code>aux_logits=False</code> in the instantiation of the model.</p>

username: Mudasser_Afzal
cooked: <p>Hi ,<br>
I have got another error saying<br>
<code>AttributeError: 'InceptionOutputs' object has no attribute 'size'</code><br>
In incpetion_v3 pretrained model. I am using focal loss which works well on other models. focal loss code is here</p>
<pre><code class="lang-auto">`def focal_loss(targets,logits,eps,l):
`    ce_loss = torch.nn.functional.binary_cross_entropy_with_logits(logits, targets, reduction= 'none')
`    pt = torch.exp(-ce_loss)
`    loss = (eps * (1-pt)**l * ce_loss).mean()
`    return loss
</code></pre>
<p>Please need help. It throws error on ce_loss statement</p>

username: ptrblck
cooked: <p><code>InceptionOutputs</code> is a <code>namedtuple</code>, which contains the attributes <code>.logits</code> and <code>.aux_logits</code>, so you would probably want to pass <code>output.logits</code> to your loss function.</p>

username: Mercy
cooked: <pre><code>x = x.view(batch_size,timesteps,-1)
</code></pre>
<p>AttributeError: ‘InceptionOutputs’ object has no attribute ‘view’<br>
I need Help</p>

username: ptrblck
cooked: <p>Does my previous message address this issue?<br>
As you can see, <code>IndeptionOutput</code> contains attributes, which you would need to access first.</p>

username: sguerin
cooked: <p>In the train and eval loop you could use something like this:</p>
<pre><code class="lang-python">output = model(input)
    if isinstance(output, tuple): # &lt;-- inception output is a tuple (x, aux)
        output = output[0]  # &lt;-- use just x
</code></pre>