Problem of the tutorial of LGNN


First of all, thanks for the great library!
I try to reproduce the tutorial of LGNN and meet an error in the ‘’.
As shown below.How can I solve it?

File “C:/Users/Desktop/”, line 544, in
loss_perm1 = F.cross_entropy(z, label)

File “C:\Programme Files\Anaconda3\lib\site-packages\torch\nn\”, line 1970, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)

File “C:\Programme Files\Anaconda3\lib\site-packages\torch\nn\”, line 1790, in nll_loss
ret = torch._C._nn.nll_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)

RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 ‘target’


Mine works fine. What’s your pytorch version and dgl version?


pytorch version:1.0.1
dgl version:0.2


It might due to the difference between operating systems. Mine is Ubuntu 16.04.

Could you try changing line 544 F.cross_entropy(z, label) to F.cross_entropy(z, label.long()) and see whether there still has errors?


Yes,you are right. Thank you for helping me with the problem.