Error in getting accuracy using test set with PyTorch
I am trying to find the accuracy of my model that I created with PyTorch, but I get an error. Originally I had a different error, which is fixed, but now I get this error.
I use this to get my test set:
testset = torchvision.datasets.FashionMNIST(MNIST_DIR, train=False,
                                       download=True, transform=torchvision.transforms.Compose([
                                            torchvision.transforms.ColorJitter(brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1),
                                            torchvision.transforms.ToTensor(), # image to Tensor
                                            torchvision.transforms.Normalize((0.1307,), (0.3081,)) # image, label
                                            ]))
testloader = torch.utils.data.DataLoader(testset, batch_size=100,
                                         shuffle=False)

When I try to access the test set I created, it tries to retrain the model for some reason, then proceeds to error out.
This is the code that gets the accuracy and calls the test set
correct = 0
total = 0
with torch.no_grad():
    print(&quot;entered here&quot;)
    for (x, y_gt) in testloader:
        x = x.to(device)
        y_gt = y_gt.to(device)
        outputs = teacher_model(x)
        _, predicted = torch.max(outputs.data, 1)
        total += labels.size(0)
        correct += (predicted == labels).sum().item()

print('Accuracy of the network on the 10000 test images: %d %%' % (100 * correct / total))

This is the error I am getting:
Traceback (most recent call last):
  File &quot;[path]/train_teacher_1.py&quot;, line 134, in &lt;module&gt;
    outputs = teacher_model(x)
  File &quot;[path]\anaconda3\lib\site-packages\torch\nn\modules\module.py&quot;, line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File &quot;[path]\models.py&quot;, line 17, in forward
    x = F.relu(self.layer1(x))
  File &quot;[path]\anaconda3\lib\site-packages\torch\nn\modules\module.py&quot;, line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File &quot;[path]\anaconda3\lib\site-packages\torch\nn\modules\linear.py&quot;, line 93, in forward
    return F.linear(input, self.weight, self.bias)
  File &quot;[path]\anaconda3\lib\site-packages\torch\nn\functional.py&quot;, line 1692, in linear
    output = input.matmul(weight.t())
RuntimeError: mat1 dim 1 must match mat2 dim 0

Please let me know if you would like the rest of the code for training the model. I left it out because the post got too long.
I am new to PyTorch and any help is appreciated. Thanks in advance.

I was able to figure out the issue and I needed to check the size of x.
I added this to the for loop to fix it:
x = torch.flatten(x, start_dim=1, end_dim=-1)
