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: 1only batches of spatial targets supported (3D tensors) but got targets of size: : [1, 1, 187, 621] #226

Closed
haixiongli opened this issue Oct 12, 2020 · 1 comment

Comments

@haixiongli
Copy link

hello, I use the new version to train with multi classes dataset of KITTI semantics. but I meet the error like this
`
INFO: Using device cuda
INFO: Network:
3 input channels
20 output channels (classes)
Bilinear upscaling
INFO: Creating dataset with 200 examples
INFO: Starting training:
Epochs: 5
Batch size: 1
Learning rate: 0.0001
Training size: 180
Validation size: 20
Checkpoints: True
Device: cuda
Images scaling: 0.5

Epoch 1/5: 0%| | 0/180 [00:00<?, ?img/s]
Traceback (most recent call last):
File "/home/lab2/work/lhx/Unet/train.py", line 179, in
val_percent=args.val / 100)
File "/home/lab2/work/lhx/Unet/train.py", line 78, in train_net
loss = criterion(masks_pred, true_masks)
File "/home/lab2/anaconda3/envs/torch1.6/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/lab2/anaconda3/envs/torch1.6/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 948, in forward
ignore_index=self.ignore_index, reduction=self.reduction)
File "/home/lab2/anaconda3/envs/torch1.6/lib/python3.6/site-packages/torch/nn/functional.py", line 2422, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/home/lab2/anaconda3/envs/torch1.6/lib/python3.6/site-packages/torch/nn/functional.py", line 2220, 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, 1, 187, 621]

`

@milesial
Copy link
Owner

Duplicate of #123

@milesial milesial marked this as a duplicate of #123 Oct 12, 2020
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