yolov5ds icon indicating copy to clipboard operation
yolov5ds copied to clipboard

weight tensor should be defined either for all or no classes

Open LIPENGAYNG opened this issue 11 months ago • 1 comments

 Epoch   gpu_mem       box       obj       cls    labels  img_size

0%| | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last): File "trainds.py", line 686, in main(opt) File "trainds.py", line 583, in main train(opt.hyp, opt, device, callbacks) File "trainds.py", line 369, in train segloss = SegLoss(seg_pred[1], segtargets.long().to(device)) # loss scaled by batch_size File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/modules/module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1047, in forward return F.cross_entropy(input, target, weight=self.weight, File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/functional.py", line 2690, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "/root/anaconda3/envs/de1/lib/python3.8/site-packages/torch/nn/functional.py", line 2387, in nll_loss ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: weight tensor should be defined either for all or no classes at /pytorch/aten/src/THCUNN/generic/SpatialClassNLLCriterion.cu:27

LIPENGAYNG avatar Feb 27 '24 09:02 LIPENGAYNG

看一下datasets.py中 读取label那里的程序,看他分了几类

DashBear avatar Apr 19 '24 09:04 DashBear