junfu1115 / DANet

Dual Attention Network for Scene Segmentation (CVPR2019)
MIT License
2.41k stars 483 forks source link

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

Open 202041600047 opened 3 years ago

202041600047 commented 3 years ago

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 commented 3 years ago

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