Solved by svd3 in post #3 
              
              
                This error is occuring because the batchsize of data and labels is not same. By batchsize I mean the 1st dimension in the size. 
try printing data.size() and labels.size() 
Also I see that your data is not a tensor, I guess it’s still a numpy array. 
Do: 
data = torch.Tensor(data) # by default its a…