I am trying to test my model with different batch sizes and I am getting different accuracies for different batch sizes. here is my test snippet. (one_hot is False!)
    for idx, data in enumerate(test_loader):
        # if idx == 1:
        #     break
        # print(model.training)
        test_x, label = data['input'], data['label']
        # print(test_x)
        # print(test_x.shape)
        # this = test_x.numpy().squeeze(0).transpose(1,2,0)
        # print(this.shape, np.min(this), np.max(this))
        if cuda:
            test_x = test_x.cuda(device=device)
            label = label.cuda(device=device)
        # forward
        out_x, pred = model.forward(test_x)
        loss = criterion(out_x, label)
        un_confusion_meter.add(predicted=pred, target=label)
        confusion_meter.add(predicted=pred, target=label)

        ###############################
        # pred = pred.view(-1)
        # pred = pred.cpu().numpy()
        # label = label.cpu().numpy()
        # print(pred.shape, label.shape)
        ###############################

        # get accuracy metric
        # correct_count += np.sum((pred == label))
        # print(pred, label)
        # get accuracy metric
        if 'one_hot' in kwargs.keys():
            if kwargs['one_hot']:
                batch_correct = (torch.argmax(label, dim=1).eq(pred.long())).double().sum().item()
        else:
            batch_correct = (label.eq(pred.long())).double().sum().item()
        correct_count += batch_correct
        # print(batch_correct)
        total_count += np.float(batch_size)
        net_loss.append(loss.item())
        if idx % log_after == 0:
            print('log: on {}'.format(idx))

        #################################
    mean_loss = np.asarray(net_loss).mean()
    mean_accuracy = correct_count * 100 / total_count
    print(correct_count, total_count)
    print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    print('log: test:: total loss = {:.5f}, total accuracy = {:.5f}%'.format(mean_loss, mean_accuracy))
    print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')

I have tried to fix all sorts of problems. Model is in .eval() mode and the function is decorated by torch.no_grad() as well. I can’t find any solution to this. Thanks