RuntimeError: The size of tensor a (32) must match the size of tensor b (23) at non-singleton dimension 1

RuntimeError                              Traceback (most recent call last)
<ipython-input-53-62648c78c606> in <module>
      6 val_loss , val_accuracy = [], []
      7 # Train and evaluate
----> 8 model, hist = train_model(model, data_loaders, criterion, optimizer_ft, num_epochs=num_epochs)

<ipython-input-43-7052c1a4d9e9> in train_model(model, dataloaders, criterion, optimizer, num_epochs)
     51                 # statistics
     52                 running_loss += loss.item() * inputs.size(0)
---> 53                 running_corrects += torch.sum(preds == labels.data)
     54 
     55             epoch_loss = running_loss / len(dataloaders[phase].dataset)

~/anaconda3/lib/python3.7/site-packages/torch/tensor.py in wrapped(*args, **kwargs)
     25             return handle_torch_function(wrapped, args, *args, **kwargs)
     26         try:
---> 27             return f(*args, **kwargs)
     28         except TypeError:
     29             return NotImplemented

RuntimeError: The size of tensor a (32) must match the size of tensor b (23) at non-singleton dimension 1

try printing the shapes for both of the tensor you are passing.

How was it solved? i have the same issue.