Problem of the tutorial of LGNN


#1

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

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

File “C:\Programme Files\Anaconda3\lib\site-packages\torch\nn\functional.py”, 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\functional.py”, 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’


#2

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


#3

pytorch version:1.0.1
dgl version:0.2


#4

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?


#5

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