After 1 epoch is completed When I run this statement evaluation(trainloader, resnet)
I get the following error
pred : tensor([3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], device=‘cuda:0’)
RuntimeError Traceback (most recent call last)
in ()
35 loss_epoch_arr.append(loss.item())
36
—> 37 print(‘Epoch: %d/%d, Train acc : %0.2f’ % (epoch, max_epochs, evaluation(trainloader,resnet)) )
38 plt.plot(loss_epoch_arr)
39 plt.show()
1 frames
/usr/local/lib/python3.6/dist-packages/torch/tensor.py in wrapped(*args, **kwargs)
26 def wrapped(*args, **kwargs):
27 try:
—> 28 return f(*args, **kwargs)
29 except TypeError:
30 return NotImplemented
RuntimeError: The size of tensor a (64) must match the size of tensor b (15) at non-singleton dimension 1
Actually I’m doing multilabel(multi-class) classifcation for the first time, so I dont know what changes need to be made in the evaluation function…I just know that BCEWithLogitLoss/BCELoss is used