Skip to content

RuntimeError #350

Closed
Closed
@wxm123wxm

Description

@wxm123wxm

How to resolve "RuntimeError: 1only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 640, 959, 3]"
The details are as followed:
Epoch 1/5: 0%| | 0/4580 [00:08<?, ?img/s]
Traceback (most recent call last):
File "/home/ubuntu/workplace/Pytorch_Unet/train.py", line 185, in
train_net(net=net,
File "/home/ubuntu/workplace/Pytorch_Unet/train.py", line 93, in train_net
loss = criterion(masks_pred, true_masks)
File "/home/ubuntu/.conda/envs/gpu/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/ubuntu/.conda/envs/gpu/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 961, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "/home/ubuntu/.conda/envs/gpu/lib/python3.8/site-packages/torch/nn/functional.py", line 2468, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/home/ubuntu/.conda/envs/gpu/lib/python3.8/site-packages/torch/nn/functional.py", line 2266, in nll_loss
ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index)
RuntimeError: 1only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 640, 959, 3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions