Skip to content

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

@202041600047

Description

@202041600047

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions