Network Only Predicts the First Image Successfuly but not the rest

miguel_angel: <p>I’m testing my network with a back of images (<a href="https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html" rel="noopener nofollow ugc">following this tutorial</a>). I’m getting the first 5 images of the batch and printing them as well as their truth labels:</p>
<pre><code class="lang-auto"># Showing the images
test_images, test_labels = next(iter(testloader))
fig = plt.figure(figsize=(15,4))

for i in range(5):
    
    ax = fig.add_subplot(1, 5, i + 1)
    plt.imshow(images[i].permute(1, 2, 0))
    plt.axis("off")

print('Truth Answer: ', ' '.join('%5s' % label_guide[labels[j]] for j in range(5)))
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/7/c7d049925fa96e3a0c901917c44138ade10f85df.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/c7d049925fa96e3a0c901917c44138ade10f85df" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c7d049925fa96e3a0c901917c44138ade10f85df_2_690x127.jpeg" alt="image" data-base62-sha1="svDgL0zy9zFBxVolMjV8uLAcFfp" width="690" height="127" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/7/c7d049925fa96e3a0c901917c44138ade10f85df_2_690x127.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/c/7/c7d049925fa96e3a0c901917c44138ade10f85df.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/c/7/c7d049925fa96e3a0c901917c44138ade10f85df.jpeg 2x" data-dominant-color="95929D"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">849×157 51 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>After, I load the model I created and pass the testing images into it for a prediction!</p>
<pre><code class="lang-auto">vehicle_classifier = Test_Network()
vehicle_classifier.load_state_dict(torch.load(PATH))
outputs = vehicle_classifier(test_images)
_, prediction = torch.max(outputs, 1)
print('Prediction: ', ' '.join(label_guide[prediction[i].item()] for i in range(5)))
</code></pre>
<p>The network seems to do fine identifying the first image (which in this case is an airplane). However, when printing the predictions for the other 4 images, it labels them all as Airplane as well. I also checked what the prediction tensor was and it labeled everything as airplane. I attached those outputs below:</p>
<pre><code class="lang-auto">Prediction:  Airplane Airplane Airplane Airplane Airplane
tensor([0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0])
</code></pre>
<p>Does anyone have an idea on why it is doing this? On the tutorial, the network had a different prediction for each image but mine seems to label all of them as the first one ):</p>

eqy: <p>It looks like you are testing images on a different dataset than the standard CIFAR10 dataset. (if my eyes don’t deceive me, these look to be much higher resolution than 32x32)</p>
<p>What size are the test images being resized to? If they are 224x224 while the model was trained on 32x32, we would expect model performance to be poor due to the scale difference in the training and testing distributions. If you’re checking the resizing in the testing dataloader, it might also be a good time to check that all of the normalizations (e.g., scaling color channels) match up with done at training time as well.</p>