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

TypeError: cross_entropy_loss(): argument 'input' (position 1) must be Tensor, not tuple #137

Open
202041600047 opened this issue Jul 12, 2021 · 1 comment

Comments

@202041600047
Copy link

Hi,When I began to train this model, this problem appeared in the loss function.

Traceback (most recent call last):
File "/home/caiweixin/Downloads/DANet-master/experiments/segmentation/train.py", line 287, in
trainer.training(epoch)
File "/home/caiweixin/Downloads/DANet-master/experiments/segmentation/train.py", line 219, in training
loss = self.criterion(outputs, target)
File "/home/caiweixin/Downloads/DANet-master/venv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/caiweixin/Downloads/DANet-master/encoding/nn/loss.py", line 69, in forward
return super(SegmentationLosses, self).forward(*inputs)
File "/home/caiweixin/Downloads/DANet-master/venv/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 1121, in forward
ignore_index=self.ignore_index, reduction=self.reduction)
File "/home/caiweixin/Downloads/DANet-master/venv/lib/python3.7/site-packages/torch/nn/functional.py", line 2824, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
TypeError: cross_entropy_loss(): argument 'input' (position 1) must be Tensor, not tuple

Process finished with exit code 1

How can I solve this problem?thank you.

@wlj567
Copy link

wlj567 commented Sep 29, 2021

@202041600047 Hello, have you passed the complete code? Is it convenient to add a contact information? Thank you!

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