Open ZzhhzZ12345679 opened 1 year ago
我在运行train.py时出现了以下报错: Traceback (most recent call last): File "train.py", line 152, in train(net, train_loader, loss_dict, optimizer, scheduler,logger, epoch, metric_dict, cfg.use_aux) File "train.py", line 68, in train loss = calc_loss(loss_dict, results, logger, global_step) File "train.py", line 47, in calc_loss loss_cur = loss_dict['op']i File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\modules\loss.py", line 1176, in forward label_smoothing=self.label_smoothing) File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\functional.py", line 3026, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [32, 36, 100, 3]
chane the use_aux to False can work: parser.add_argument('--use_aux', default='False', type=str2bool)
我也遇到了这个问题,应该是因为CULane的seg label是个1通道的png,我的数据集的seg label是个3通道的,调整一下label维度就好了
怎么调整这个维度
我在运行train.py时出现了以下报错: Traceback (most recent call last): File "train.py", line 152, in
train(net, train_loader, loss_dict, optimizer, scheduler,logger, epoch, metric_dict, cfg.use_aux)
File "train.py", line 68, in train
loss = calc_loss(loss_dict, results, logger, global_step)
File "train.py", line 47, in calc_loss
loss_cur = loss_dict['op']i
File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl
return forward_call(*input, **kwargs)
File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\modules\loss.py", line 1176, in forward
label_smoothing=self.label_smoothing)
File "D:\anaconda\envs\lane\lib\site-packages\torch\nn\functional.py", line 3026, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [32, 36, 100, 3]