@ptrblck_de Thank you for formatting my code in the post.
I have tried to add the .long() to my NosiyMNISTDataset class as
                       self.y_data = torch.from_numpy(xy[:, [0]]).long()

and add a print function under the training loop
labels = Variable(labels.cuda())
print(labels.shape)
it gave “torch.Size([100,1])”  (matches with my batch size).
However, it still has an error as follows:
“RuntimeError: multi-target not supported at c:\programdata\miniconda3\conda-bld\pytorch_1533090623466\work\aten\src\thcunn\generic/ClassNLLCriterion.cu:15”