Hi,
I am trying to run inference on an image classification task for 4 images.
I am getting
  File "inference.py", line 88, in accuracy     test_correct += np.sum(np.squeeze(pred.eq(target.data.view_as(pred)).cpu().numpy())) # noqa RuntimeError: shape '[1, 1, 4]' is invalid for input of size 12
I am quite not sure where I am doing wrong,as the same code is working fine when I am running along with training loop for training set.
Below is my code for testing -
def accuracy(model, loader, criterion, use_cuda=False):
    """Calculate Accuracy."""
    test_accuracy = 0.0
    test_loss = 0.0
    test_correct = 0.0
    test_total = 0.0
    model.eval()
    for batch_idx, (data, target) in enumerate(loader):
        # move to GPU
        if use_cuda:
            data, target = data.cuda(), target.cuda()
        # update the average validation loss
        output = model(data).squeeze()
        output = torch.unsqueeze(output, 0)
        pred = output.data.max(1, keepdim=True)[1]
        test_correct += np.sum(np.squeeze(pred.eq(target.data.view_as(pred)).cpu().numpy())) # noqa
        test_total += data.size(0)
    test_accuracy = 100. * (test_correct/test_total)
    print(test_accuracy)
    return None