Hello please kindly look at this error. Whenever I try to train my dataset by using train.py I keep getting this error. As I am new to pytorch a little guidance would be helpful.
RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [1, 512, 512, 3]
Traceback (most recent call last):
File "train.py", line 60, in
metric_list=metric_list, verbose=True)
File "/home/shrutika/pytorch-UNet-master/pytorch-UNet-master/unet/model.py", line 186, in fit_dataset
train_logs = self.fit_epoch(dataset, n_batch=n_batch, shuffle=shuffle)
File "/home/shrutika/pytorch-UNet-master/pytorch-UNet-master/unet/model.py", line 99, in fit_epoch
training_loss = self.loss(y_out, y_batch)
File "/home/shrutika/anaconda3/envs/3dunet/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/home/shrutika/pytorch-UNet-master/pytorch-UNet-master/unet/metrics.py", line 20, in forward
ignore_index=self.ignore_index)
File "/home/shrutika/anaconda3/envs/3dunet/lib/python3.7/site-packages/torch/nn/functional.py", line 2021, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/home/shrutika/anaconda3/envs/3dunet/lib/python3.7/site-packages/torch/nn/functional.py", line 1840, 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 (non-empty 3D tensors) but got targets of size: : [1, 512, 512, 3]
Hello please kindly look at this error. Whenever I try to train my dataset by using train.py I keep getting this error. As I am new to pytorch a little guidance would be helpful. RuntimeError: 1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size: : [1, 512, 512, 3]
Thank you in advance.