Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Peterdingpeng opened this issue Dec 24, 2019 · 1 comment

Comments

@Peterdingpeng
Copy link

Traceback (most recent call last):
File "C:/Users/Dingd/Documents/GitHub/MAML-Pytorch-master/omniglot_train.py", line 95, in
main(args)
File "C:/Users/Dingd/Documents/GitHub/MAML-Pytorch-master/omniglot_train.py", line 55, in main
accs = maml(x_spt, y_spt, x_qry, y_qry)
File "C:\Users\Dingd\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "C:\Users\Dingd\Documents\GitHub\MAML-Pytorch-master\meta.py", line 85, in forward
loss = F.cross_entropy(logits, y_spt[i])
File "C:\Users\Dingd\AppData\Local\Programs\Python\Python36\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:\Users\Dingd\AppData\Local\Programs\Python\Python36\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'

@BigWZhu
Copy link

BigWZhu commented Jan 28, 2020

in the training file you run, change following:

accs = maml(x_spt, y_spt.long(), x_qry, y_qry.long())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants