Getting very less test accuracy for ImageNet Dataset

username: Soumyajit_Das
cooked: <p>Here I  chose 20 Classes from the ImageNet Dataset and trained it with finetuned VGG16 model.<br>
The training accuracy is increasing but the test accuracy is not increasing.<br>
The following code is used for this purpose:<br>
[Note:- I attached the output log at the end of this code.]</p>
<pre><code class="lang-auto">import torch
import torchvision
from torchvision import datasets
import torchvision.transforms as transforms
import os
from model.vgg import *

import sys
file=open('output.txt','a')
sys.stdout=file



ImageNetTrain="/home/students/soumyajit_po/hsd_cnn_code/SOUMYA/ImagenetData/twentyClasses/Imagenet_Sample/train"

ImageNetVal="/home/students/soumyajit_po/hsd_cnn_code/SOUMYA/ImagenetData/twentyClasses/Imagenet_Sample/val"

transform_train = transforms.Compose([transforms.Resize(256),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize((0.485, 0.456, 0.406), (0.229,0.224,0.225)),])

trainset=torchvision.datasets.ImageFolder(root=ImageNetTrain,transform=transform_train)
trainloader=torch.utils.data.DataLoader(trainset,batch_size=256,shuffle=False,num_workers=8,pin_memory=True)

transform_test = transforms.Compose([transforms.Resize(256),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),])

testset=torchvision.datasets.ImageFolder(root=ImageNetVal,transform=transform_test)
testloader=torch.utils.data.DataLoader(testset,batch_size=256,shuffle=False,num_workers=8,pin_memory=True)

import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import matplotlib.pyplot as plt
device=torch.device("cuda:1" if torch.cuda.is_available() else "cpu")
#print("device:",device
model=cifar_vgg_net
print(model)
print("device:",device)
#for param in model.parameters():
#  param.requires_grad=True

class AverageMeter(object):
    def __init__(self):
        self.reset()
    def reset(self):
        self.val=0
        self.avg=0
        self.SUM=0
        self.count=0
    def update(self,val,n=1):
        self.val=val
        self.SUM+=val*n
        self.count+=n
        self.avg=self.SUM/self.count

def accuracy(output,target,topk=(1,)):
#"""Computes the accuracy over the k top predictions for the specified values of k"""
    with torch.no_grad():
         maxk=max(topk)
         batch_size=target.size(0)
         _,pred=output.topk(maxk,1,True,True)
         pred=torch.transpose(pred,0,1)
         correct=pred.eq(target.view(1,-1).expand_as(pred))

         res=[]
         for k in topk:
             correct_k=correct[:k].view(-1).float().sum(0,keepdim=True)
             res.append(correct_k.mul_(100.0/batch_size))
         return res


PATH='./checkpoint/vggImageNet.pth.tar'
#batch_size=128
num_epochs=75
model.to(device)
criterion=nn.CrossEntropyLoss()
#optimizer=optim.Adam(model.parameters(),lr=0.0001)
optimizer=optim.SGD(model.vggnet.parameters(),0.001,momentum=0.9)

torch.cuda.empty_cache()
#print("cleared")
globaliter=-1
best_accuracy=0
trainLOSS=[]
testACC=[]
testLOSS=[]
avg_train=0
avg_test_loss=0
for epoch in range(num_epochs):
    globaliter+=1
    running_loss=0
    total=0
    avg_train=0
    correct_classified=0
    model.train()
    for i,(inputs,labels) in enumerate(trainloader):
        inputs=inputs.to(device)
        labels=labels.to(device)
        optimizer.zero_grad()
        outputs=model(inputs)
        loss=criterion(outputs,labels)
        loss.backward()
        optimizer.step()
        predicted=torch.argmax(outputs,1)
        total+=labels.size(0)
        correct_classified+=(predicted==labels).sum().item()
        running_loss+=loss.item()
        if i%200==199:
          #avg_loss=running_loss/200
          print('Epoch:[%d, %5d] ' % (epoch+1,i+1))
          #tb.save_value('Train Loss','train_loss',globaliter,loss.item())
        
    train_acc=100*(correct_classified/total)
    avg_train=float(running_loss)/total    
    trainLOSS.append(avg_train)    
        
    print('Train Accuracy:%.3f'%(train_acc))
    print('Train Average Loss:%.4f'%(avg_train))
    
    c=0
    total=0
    globaliter=-1
    l=0
    j=-1
    top1=AverageMeter()
    top5=AverageMeter()
    model.eval()
    with torch.no_grad():
      for data in testloader:
        globaliter+=1
        j=j+1
        inputs,labels=data
        inputs,labels=inputs.to(device),labels.to(device)
        optimizer.zero_grad()
        outputs=model(inputs)
        loss=criterion(outputs,labels)
        l=l+loss.item()
        predicted=torch.argmax(outputs,1)
        total+=labels.size(0)
        c+=(predicted==labels).sum().item()
        acc1,acc5=accuracy(outputs,labels,topk=(1,5))
        top1.update(acc1[0],inputs.size(0))
        top5.update(acc5[0],inputs.size(0))        
        #if j%200==199:
          #testLOSS.append(loss.item())
          #tb.save_value('Validation Loss','validation_loss',globaliter,loss.item())
    test_acc=(100*c/total)
    if(test_acc&gt;best_accuracy):
        best_accuracy=test_acc
        print('Saving...')
        state={'net':model,'acc':best_accuracy,'epoch':epoch}
       # state={'state_dict':model.state_dict(),'optimizer':optimizer.state_dict(),'epoch':epoch,'acc':best_accuracy}
        if not os.path.isdir('checkpoint'):
           os.mkdir('checkpoint')
        torch.save(state,PATH)
       # torch.save(model,PATH)
       # torch.save(model.state_dict(),PATH)
    print('Accuracy of the network on test images:%.3f %%' % test_acc)
    print('Top1 accuracy:%.3f %%',top1.avg)
    print('Top5 accuracy:%.3f %%',top5.avg)

    testACC.append(test_acc)
    avg_test_loss=float(l)/total
    testLOSS.append(avg_test_loss)
    fig1 = plt.figure(1)        
    plt.plot(range(epoch+1),trainLOSS,'r-',label='train loss')
    plt.plot(range(epoch+1),testLOSS,'g-',label='test loss')
    if epoch==0:
      plt.legend(loc='upper left')
      plt.xlabel('Epochs')
      plt.ylabel('Loss')
    fig2 = plt.figure(2)        
    plt.plot(range(epoch+1),testACC,'g-',label='test')        
    if epoch==0:
      plt.legend(loc='upper left')
      plt.xlabel('Epochs')
      plt.ylabel('Testing Accuracy')    
              
print('Best Accuracy of the network on test images:%.3f %%'% best_accuracy)
fig1.savefig('trainloss_vs_epoch.png')
fig2.savefig('testacc_vs_epoch.png')

file.close()
</code></pre>
<p>OUTPUT LOG:</p>
<pre><code class="lang-auto">Epoch:[1,   200] 
Epoch:[1,   400] 
Epoch:[1,   600] 
Epoch:[1,   800] 
Train Accuracy:53.731
Train Average Loss:0.0661
Saving...
Accuracy of the network on test images:5.000 %
Top1 accuracy:%.3f %% tensor(5., device='cuda:1')
Top5 accuracy:%.3f %% tensor(32.6000, device='cuda:1')
Epoch:[2,   200] 
Epoch:[2,   400] 
Epoch:[2,   600] 
Epoch:[2,   800] 
Train Accuracy:61.538
Train Average Loss:0.0605
Accuracy of the network on test images:5.000 %
Top1 accuracy:%.3f %% tensor(5., device='cuda:1')
Top5 accuracy:%.3f %% tensor(43.9000, device='cuda:1')
Epoch:[3,   200] 
Epoch:[3,   400] 
Epoch:[3,   600] 
Epoch:[3,   800] 
Train Accuracy:71.985
Train Average Loss:0.0460
Accuracy of the network on test images:5.000 %
Top1 accuracy:%.3f %% tensor(5., device='cuda:1')
Top5 accuracy:%.3f %% tensor(55.2000, device='cuda:1')
Epoch:[4,   200] 
Epoch:[4,   400] 
Epoch:[4,   600] 
Epoch:[4,   800] 
Train Accuracy:75.273
Train Average Loss:0.0409
Accuracy of the network on test images:5.000 %
Top1 accuracy:%.3f %% tensor(5., device='cuda:1')
Top5 accuracy:%.3f %% tensor(38.2000, device='cuda:1')
Epoch:[5,   200] 
Epoch:[5,   400] 
Epoch:[5,   600] 
Epoch:[5,   800] 
Train Accuracy:73.815
Train Average Loss:0.0407
Saving...
Accuracy of the network on test images:6.100 %
Top1 accuracy:%.3f %% tensor(6.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(59.5000, device='cuda:1')
Epoch:[6,   200] 
Epoch:[6,   400] 
Epoch:[6,   600] 
Epoch:[6,   800] 
Train Accuracy:74.842
Train Average Loss:0.0384
Accuracy of the network on test images:5.200 %
Top1 accuracy:%.3f %% tensor(5.2000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(46.0000, device='cuda:1')
Epoch:[7,   200] 
Epoch:[7,   400] 
Epoch:[7,   600] 
Epoch:[7,   800] 
Train Accuracy:75.823
Train Average Loss:0.0329
Saving...
Accuracy of the network on test images:8.700 %
Top1 accuracy:%.3f %% tensor(8.7000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(69.8000, device='cuda:1')
Epoch:[8,   200] 
Epoch:[8,   400] 
Epoch:[8,   600] 
Epoch:[8,   800] 
Train Accuracy:78.365
Train Average Loss:0.0281
Saving...
Accuracy of the network on test images:18.800 %
Top1 accuracy:%.3f %% tensor(18.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(65.2000, device='cuda:1')
Epoch:[9,   200] 
Epoch:[9,   400] 
Epoch:[9,   600] 
Epoch:[9,   800] 
Train Accuracy:82.696
Train Average Loss:0.0196
Accuracy of the network on test images:11.600 %
Top1 accuracy:%.3f %% tensor(11.6000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(59.7000, device='cuda:1')
Epoch:[10,   200] 
Epoch:[10,   400] 
Epoch:[10,   600] 
Epoch:[10,   800] 
Train Accuracy:87.354
Train Average Loss:0.0134
Accuracy of the network on test images:10.200 %
Top1 accuracy:%.3f %% tensor(10.2000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(55.4000, device='cuda:1')
Epoch:[11,   200] 
Epoch:[11,   400] 
Epoch:[11,   600] 
Epoch:[11,   800] 
Train Accuracy:90.804
Train Average Loss:0.0094
Accuracy of the network on test images:10.100 %
Top1 accuracy:%.3f %% tensor(10.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(49.9000, device='cuda:1')
Epoch:[12,   200] 
Epoch:[12,   400] 
Epoch:[12,   600] 
Epoch:[12,   800] 
Train Accuracy:93.988
Train Average Loss:0.0061
Accuracy of the network on test images:10.800 %
Top1 accuracy:%.3f %% tensor(10.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(43.7000, device='cuda:1')
Epoch:[13,   200] 
Epoch:[13,   400] 
Epoch:[13,   600] 
Epoch:[13,   800] 
Train Accuracy:96.496
Train Average Loss:0.0039
Accuracy of the network on test images:11.900 %
Top1 accuracy:%.3f %% tensor(11.9000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(44.6000, device='cuda:1')
Epoch:[14,   200] 
Epoch:[14,   400] 
Epoch:[14,   600] 
Epoch:[14,   800] 
Train Accuracy:97.942
Train Average Loss:0.0027
Accuracy of the network on test images:12.800 %
Top1 accuracy:%.3f %% tensor(12.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(44.5000, device='cuda:1')
Epoch:[15,   200] 
Epoch:[15,   400] 
Epoch:[15,   600] 
Epoch:[15,   800] 
Train Accuracy:98.646
Train Average Loss:0.0019
Accuracy of the network on test images:13.500 %
Top1 accuracy:%.3f %% tensor(13.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(43.6000, device='cuda:1')
Epoch:[16,   200] 
Epoch:[16,   400] 
Epoch:[16,   600] 
Epoch:[16,   800] 
Train Accuracy:98.958
Train Average Loss:0.0015
Accuracy of the network on test images:10.700 %
Top1 accuracy:%.3f %% tensor(10.7000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(39.9000, device='cuda:1')
Epoch:[17,   200] 
Epoch:[17,   400] 
Epoch:[17,   600] 
Epoch:[17,   800] 
Train Accuracy:98.950
Train Average Loss:0.0015
Accuracy of the network on test images:11.500 %
Top1 accuracy:%.3f %% tensor(11.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(39.7000, device='cuda:1')
Epoch:[18,   200] 
Epoch:[18,   400] 
Epoch:[18,   600] 
Epoch:[18,   800] 
Train Accuracy:99.385
Train Average Loss:0.0010
Accuracy of the network on test images:11.600 %
Top1 accuracy:%.3f %% tensor(11.6000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(39.1000, device='cuda:1')
Epoch:[19,   200] 
Epoch:[19,   400] 
Epoch:[19,   600] 
Epoch:[19,   800] 
Train Accuracy:99.504
Train Average Loss:0.0009
Accuracy of the network on test images:14.100 %
Top1 accuracy:%.3f %% tensor(14.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.5000, device='cuda:1')
Epoch:[20,   200] 
Epoch:[20,   400] 
Epoch:[20,   600] 
Epoch:[20,   800] 
Train Accuracy:99.777
Train Average Loss:0.0006
Accuracy of the network on test images:14.500 %
Top1 accuracy:%.3f %% tensor(14.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(43.8000, device='cuda:1')
Epoch:[21,   200] 
Epoch:[21,   400] 
Epoch:[21,   600] 
Epoch:[21,   800] 
Train Accuracy:99.788
Train Average Loss:0.0005
Accuracy of the network on test images:13.400 %
Top1 accuracy:%.3f %% tensor(13.4000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(42.8000, device='cuda:1')
Epoch:[22,   200] 
Epoch:[22,   400] 
Epoch:[22,   600] 
Epoch:[22,   800] 
Train Accuracy:99.908
Train Average Loss:0.0004
Accuracy of the network on test images:14.500 %
Top1 accuracy:%.3f %% tensor(14.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(47.6000, device='cuda:1')
Epoch:[23,   200] 
Epoch:[23,   400] 
Epoch:[23,   600] 
Epoch:[23,   800] 
Train Accuracy:98.427
Train Average Loss:0.0031
Accuracy of the network on test images:12.800 %
Top1 accuracy:%.3f %% tensor(12.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(50.5000, device='cuda:1')
Epoch:[24,   200] 
Epoch:[24,   400] 
Epoch:[24,   600] 
Epoch:[24,   800] 
Train Accuracy:96.850
Train Average Loss:0.0050
Accuracy of the network on test images:15.400 %
Top1 accuracy:%.3f %% tensor(15.4000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(55.0000, device='cuda:1')
Epoch:[25,   200] 
Epoch:[25,   400] 
Epoch:[25,   600] 
Epoch:[25,   800] 
Train Accuracy:98.850
Train Average Loss:0.0017
Accuracy of the network on test images:16.900 %
Top1 accuracy:%.3f %% tensor(16.9000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(54.8000, device='cuda:1')
Epoch:[26,   200] 
Epoch:[26,   400] 
Epoch:[26,   600] 
Epoch:[26,   800] 
Train Accuracy:99.246
Train Average Loss:0.0011
Accuracy of the network on test images:18.100 %
Top1 accuracy:%.3f %% tensor(18.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(56.4000, device='cuda:1')
Epoch:[27,   200] 
Epoch:[27,   400] 
Epoch:[27,   600] 
Epoch:[27,   800] 
Train Accuracy:99.469
Train Average Loss:0.0008
Accuracy of the network on test images:17.000 %
Top1 accuracy:%.3f %% tensor(17., device='cuda:1')
Top5 accuracy:%.3f %% tensor(51.5000, device='cuda:1')
Epoch:[28,   200] 
Epoch:[28,   400] 
Epoch:[28,   600] 
Epoch:[28,   800] 
Train Accuracy:99.812
Train Average Loss:0.0004
Accuracy of the network on test images:17.100 %
Top1 accuracy:%.3f %% tensor(17.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(50.9000, device='cuda:1')
Epoch:[29,   200] 
Epoch:[29,   400] 
Epoch:[29,   600] 
Epoch:[29,   800] 
Train Accuracy:99.896
Train Average Loss:0.0003
Accuracy of the network on test images:16.400 %
Top1 accuracy:%.3f %% tensor(16.4000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(48.7000, device='cuda:1')
Epoch:[30,   200] 
Epoch:[30,   400] 
Epoch:[30,   600] 
Epoch:[30,   800] 
Train Accuracy:100.000
Train Average Loss:0.0002
Accuracy of the network on test images:15.900 %
Top1 accuracy:%.3f %% tensor(15.9000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(47.2000, device='cuda:1')
Epoch:[31,   200] 
Epoch:[31,   400] 
Epoch:[31,   600] 
Epoch:[31,   800] 
Train Accuracy:99.977
Train Average Loss:0.0002
Accuracy of the network on test images:16.100 %
Top1 accuracy:%.3f %% tensor(16.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(47.2000, device='cuda:1')
Epoch:[32,   200] 
Epoch:[32,   400] 
Epoch:[32,   600] 
Epoch:[32,   800] 
Train Accuracy:99.988
Train Average Loss:0.0001
Accuracy of the network on test images:15.100 %
Top1 accuracy:%.3f %% tensor(15.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(45.8000, device='cuda:1')
Epoch:[33,   200] 
Epoch:[33,   400] 
Epoch:[33,   600] 
Epoch:[33,   800] 
Train Accuracy:99.973
Train Average Loss:0.0001
Accuracy of the network on test images:14.100 %
Top1 accuracy:%.3f %% tensor(14.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(45.3000, device='cuda:1')
Epoch:[34,   200] 
Epoch:[34,   400] 
Epoch:[34,   600] 
Epoch:[34,   800] 
Train Accuracy:99.942
Train Average Loss:0.0001
Accuracy of the network on test images:13.800 %
Top1 accuracy:%.3f %% tensor(13.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(45.3000, device='cuda:1')
Epoch:[35,   200] 
Epoch:[35,   400] 
Epoch:[35,   600] 
Epoch:[35,   800] 
Train Accuracy:99.942
Train Average Loss:0.0001
Accuracy of the network on test images:13.200 %
Top1 accuracy:%.3f %% tensor(13.2000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(44.5000, device='cuda:1')
Epoch:[36,   200] 
Epoch:[36,   400] 
Epoch:[36,   600] 
Epoch:[36,   800] 
Train Accuracy:99.950
Train Average Loss:0.0001
Accuracy of the network on test images:14.800 %
Top1 accuracy:%.3f %% tensor(14.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(47.9000, device='cuda:1')
Epoch:[37,   200] 
Epoch:[37,   400] 
Epoch:[37,   600] 
Epoch:[37,   800] 
Train Accuracy:99.954
Train Average Loss:0.0001
Accuracy of the network on test images:13.800 %
Top1 accuracy:%.3f %% tensor(13.8000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(45.3000, device='cuda:1')
Epoch:[38,   200] 
Epoch:[38,   400] 
Epoch:[38,   600] 
Epoch:[38,   800] 
Train Accuracy:99.988
Train Average Loss:0.0001
Accuracy of the network on test images:13.700 %
Top1 accuracy:%.3f %% tensor(13.7000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(43.8000, device='cuda:1')
Epoch:[39,   200] 
Epoch:[39,   400] 
Epoch:[39,   600] 
Epoch:[39,   800] 
Train Accuracy:99.977
Train Average Loss:0.0001
Accuracy of the network on test images:13.100 %
Top1 accuracy:%.3f %% tensor(13.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(42.5000, device='cuda:1')
Epoch:[40,   200] 
Epoch:[40,   400] 
Epoch:[40,   600] 
Epoch:[40,   800] 
Train Accuracy:99.996
Train Average Loss:0.0000
Accuracy of the network on test images:12.700 %
Top1 accuracy:%.3f %% tensor(12.7000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.6000, device='cuda:1')
Epoch:[41,   200] 
Epoch:[41,   400] 
Epoch:[41,   600] 
Epoch:[41,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:13.000 %
Top1 accuracy:%.3f %% tensor(13.0000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.9000, device='cuda:1')
Epoch:[42,   200] 
Epoch:[42,   400] 
Epoch:[42,   600] 
Epoch:[42,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.700 %
Top1 accuracy:%.3f %% tensor(12.7000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.5000, device='cuda:1')
Epoch:[43,   200] 
Epoch:[43,   400] 
Epoch:[43,   600] 
Epoch:[43,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.600 %
Top1 accuracy:%.3f %% tensor(12.6000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.6000, device='cuda:1')
Epoch:[44,   200] 
Epoch:[44,   400] 
Epoch:[44,   600] 
Epoch:[44,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.500 %
Top1 accuracy:%.3f %% tensor(12.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.5000, device='cuda:1')
Epoch:[45,   200] 
Epoch:[45,   400] 
Epoch:[45,   600] 
Epoch:[45,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.500 %
Top1 accuracy:%.3f %% tensor(12.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.5000, device='cuda:1')
Epoch:[46,   200] 
Epoch:[46,   400] 
Epoch:[46,   600] 
Epoch:[46,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.500 %
Top1 accuracy:%.3f %% tensor(12.5000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.4000, device='cuda:1')
Epoch:[47,   200] 
Epoch:[47,   400] 
Epoch:[47,   600] 
Epoch:[47,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.300 %
Top1 accuracy:%.3f %% tensor(12.3000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.3000, device='cuda:1')
Epoch:[48,   200] 
Epoch:[48,   400] 
Epoch:[48,   600] 
Epoch:[48,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.100 %
Top1 accuracy:%.3f %% tensor(12.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.1000, device='cuda:1')
Epoch:[49,   200] 
Epoch:[49,   400] 
Epoch:[49,   600] 
Epoch:[49,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.100 %
Top1 accuracy:%.3f %% tensor(12.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(41.0000, device='cuda:1')
Epoch:[50,   200] 
Epoch:[50,   400] 
Epoch:[50,   600] 
Epoch:[50,   800] 
Train Accuracy:100.000
Train Average Loss:0.0000
Accuracy of the network on test images:12.100 %
Top1 accuracy:%.3f %% tensor(12.1000, device='cuda:1')
Top5 accuracy:%.3f %% tensor(40.9000, device='cuda:1')
</code></pre>
<p>Following are the graphs <strong>train loss and test loss vs epoch</strong> and <strong>testaccuracy vs epoch</strong></p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/3/3746552b874c72c48b2f677f928bd167107851ab.png" alt="trainloss_vs_epoch" data-base62-sha1="7SYWM26T6A87DGxeezYeZoHNv3d" width="480" height="360"></p>
<p><img src="https://discuss.pytorch.org/uploads/default/original/2X/5/5bb377af49564533b04ca2b8f7e330eca842827b.png" alt="testacc_vs_epoch" data-base62-sha1="d5dXlsxFUmRCZd1dQLlygsCwcXx" width="480" height="360"></p>
<p>Why is the test accuracy so less and also so varying???<br>
Also why is the test loss so high?</p>

username: Soumyajit_Das
cooked: <p>Any suggestions will be helpful.</p>