Pretrained model accuracy is so fool

wonchulSon: <pre><code class="lang-auto">import torch
import torch.nn as nn
import time
import numpy as np
import os
from Cifar10 import dataloader
import torchvision.models as models

os.environ['CUDA_VISIBLE_DEVICES'] = '2'

test_loader = dataloader.get_test_loader('../../../../data/cifar10/',
                                         batch_size=125,
                                        )

device = 'cuda'

vgg16 = models.vgg16(pretrained=True).to(device)

criterion = nn.CrossEntropyLoss().cuda()


def test():
    vgg16.eval()
    test_loss = 0
    correct = 0
    total = 0
    global total_acc_test_max
    acc_test_max = []

    with torch.no_grad():
        for batch_idx, (images, labels) in enumerate(test_loader):
            images, labels = images.to(device), labels.to(device)
            outputs = vgg16(images)

            loss = criterion(outputs, labels)
            test_loss += loss.data
            _, predicted = torch.max(outputs.data, 1)
            total += labels.size(0)
            correct += predicted.eq(labels.data).cpu().sum()

            if batch_idx % 10 == 9:
                acc_test_max.append(100. * correct.item() / total)
                total_acc_test_max.append(100. * correct.item() / total)
                print('[TEST] : Loss: ({:.4f}) | Acc: ({:.2f}%) ({}/{})'
                      .format(test_loss / (batch_idx + 1), 100. * correct.item() / total, correct, total))

        print('*************** Val Mean Accuracy : ({:.2f}%) ***************'.format(np.mean(acc_test_max)))
        print('************ Total Val Mean Accuracy : ({:.2f}%) ************'.format(np.mean(total_acc_test_max)))
        print()


start_time = time.time()
total_acc_test_max = []
for epoch in range(0, 5):
    print("*************** {} ***************".format(epoch + 1))
    test()


print("--- {:.0f} minutes {:.2f} seconds ---".format((time.time() - start_time) // 60, (time.time() - start_time) % 60))
</code></pre>
<p>I load vgg16 pretrained weight, and test it.<br>
But the accuracy is so low.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/1/713978ded131a6a5e2b351467d5efb5ae2438759.png" data-download-href="https://discuss.pytorch.org/uploads/default/713978ded131a6a5e2b351467d5efb5ae2438759" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/7/1/713978ded131a6a5e2b351467d5efb5ae2438759.png" alt="image" data-base62-sha1="g9D5r1bnUu8x8QKbus0kdYWDLip" width="690" height="269" data-dominant-color="363636"><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">704×275 38.3 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><br>
What is the problem?</p>

ptrblck: <p>How did you define <code>test_loader</code>?<br>
Make sure to use the same preprocessing as was applied during training.</p>

wonchulSon: <p><a class="mention" href="/u/ptrblck">@ptrblck</a><br>
After load pretrained weight, it doesn’t need to train again right?<br>
So I just tested it to check accuracy, didn’t retrain it.<br>
But the result is like that.<br>
I don’t understand which is problem yet.</p>

Abhilash_Srivastava: <p>You can get decent results without retraining. But, make sure your input and output formats are as expected (for VGG16).</p>

wonchulSon: <p><a class="mention" href="/u/abhilash_srivastava">@Abhilash_Srivastava</a> <a class="mention" href="/u/ptrblck">@ptrblck</a><br>
Is pytorch pretrained model used ImageNet?<br>
So, after pretrained model and weight, should I test it only with ImageNet?<br>
I tested it with Cifar10.</p>