问题遇到的现象和发生背景
UNet网络使用Pytorch训练时报错Target 255 is out of bounds.
问题相关代码,请勿粘贴截图
:\Anaconda\Anaconda\envs\PyTorch\lib\site-packages\torch\autocast_mode.py:162: UserWarning: User provided device_type of 'cuda', but CUDA is not available. Disabling
warnings.warn('User provided device_type of \'cuda\', but CUDA is not available. Disabling')
Epoch 1/5: 0%| | 0/5 [00:04<?, ?img/s]
Traceback (most recent call last):
File "c:\Users\18497\Downloads\Pytorch-UNet-master\Pytorch-UNet-master\train.py", line 185, in <module>
train_net(net=net,
File "c:\Users\18497\Downloads\Pytorch-UNet-master\Pytorch-UNet-master\train.py", line 93, in train_net
loss = criterion(masks_pred, true_masks) \
File "D:\Anaconda\Anaconda\envs\PyTorch\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "D:\Anaconda\Anaconda\envs\PyTorch\lib\site-packages\torch\nn\modules\loss.py", line 1163, in forward
return F.cross_entropy(input, target, weight=self.weight,
File "D:\Anaconda\Anaconda\envs\PyTorch\lib\site-packages\torch\nn\functional.py", line 2996, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
IndexError: Target 255 is out of bounds.
我的解答思路和尝试过的方法
我想要达到的结果
我想请问一下,这个Target 255是代表我设定的类别有255类吗,有关类别的代码模块一般在什么位置呀?我使用自己的数据集但是不知道有哪些地方需要修改代码里的参数ww,dl帮帮我看看,答疑解惑,谢谢!!