davidtvs / PyTorch-ENet

PyTorch implementation of ENet
MIT License
389 stars 129 forks source link

Wrong about train. #34

Closed JamesZhangjp closed 4 years ago

JamesZhangjp commented 4 years ago

meet the error when i train,I haven't changed any code. I've tried to modify the dimensions of label and outputs,But it still doesn't work. Looking forward to your reply Traceback (most recent call last): File "PyTorch-ENet/run.py", line 305, in <module> model = train(train_loader, val_loader, w_class, class_encoding) File "PyTorch-ENet/run.py", line 192, in train epoch_loss, (iou, miou) = train.run_epoch(args.print_step) File "PyTorch-ENet\train.py", line 47, in run_epoch loss = self.criterion(outputs, labels) File "Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__ result = self.forward(*input, **kwargs) File "Anaconda3\lib\site-packages\torch\nn\modules\loss.py", line 904, in forward ignore_index=self.ignore_index, reduction=self.reduction) File "Anaconda3\lib\site-packages\torch\nn\functional.py", line 1970, in cross_entropy return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction) File "Anaconda3\lib\site-packages\torch\nn\functional.py", line 1792, in nll_loss ret = torch._C._nn.nll_loss2d(input, target, weight, _Reduction.get_enum(reduction), ignore_index) RuntimeError: invalid argument 3: only batches of spatial targets supported (3D tensors) but got targets of dimension: 4 at c:\a\w\1\s\windows\pytorch\aten\src\thnn\generic/SpatialClassNLLCriterion.c:59