# How to do inference/calculate accuracy on the entire test set

I am getting very slow inference rates by creating a test dataloader with batch size of 10k(Fashion MNIST)
Is there any better faster way to do the same

import numpy as np
import matplotlib.pyplot as plt
from torchvision import datasets,transforms
count=0
class Model(nn.Module):
def init(self):
super().init()
self.l1 = nn.Linear(in_features=784,out_features=1000,bias=False)
self.l2= nn.Linear(in_features=1000,out_features=1000,bias=False)
self.l3 = nn.Linear(in_features=1000,out_features= 500,bias=False)
self.l4 = nn.Linear(in_features=500,out_features=200,bias=False)
self.l5 = nn.Linear(in_features=200,out_features=10,bias=False)
def forward(self,x):
x = x.view(x.shape[0],-1)
x = nn.functional.relu(self.l1(x))
x = nn.functional.relu(self.l2(x))
x = nn.functional.relu(self.l3(x))
x = nn.functional.relu(self.l4(x))
x = nn.functional.log_softmax(self.l5(x), dim=1)
return x
transform = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5,0.5,0.5), (0.5,0.5,0.5))])
def test(i):
global count
title_order = [‘T-shirt/top’,
‘Trouser’,
‘Pullover’,
‘Dress’,
‘Coat’,
‘Sandal’,
‘Shirt’,
‘Sneaker’,
‘Bag’,
‘Ankle Boot’]
images, labels = dataiter.next()
img = images[i]
lbl = labels[i]
output = model.forward(img)
c_number=np.argmax(output)
if title_order[lbl]==title_order[c_number]:
count = count+1
model=Model()
model.eval()