BasicSR icon indicating copy to clipboard operation
BasicSR copied to clipboard

训练ESRGAN scale=2的模型报错

Open xiaoxiongli opened this issue 3 years ago • 1 comments

你好, 训练ESRGAN scale=2的模型报错,报错信息如下:

/data1/lishaoxiong/sr/ESRGAN/BasicSR/basicsr/losses/losses.py:16: UserWarning: Using a target size (torch.Size([2, 3, 128, 128])) that is different to the input size (torch.Size([2, 3, 256, 256])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. return F.l1_loss(pred, target, reduction='none') Traceback (most recent call last): File "basicsr/train.py", line 215, in train_pipeline(root_path) File "basicsr/train.py", line 169, in train_pipeline model.optimize_parameters(current_iter) File "/data1/lishaoxiong/sr/ESRGAN/BasicSR/basicsr/models/sr_model.py", line 100, in optimize_parameters l_pix = self.cri_pix(self.output, self.gt) File "/home/ubuntu/anaconda3/envs/pytorch1.7.1_py3.8/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/data1/lishaoxiong/sr/ESRGAN/BasicSR/basicsr/losses/losses.py", line 54, in forward return self.loss_weight * l1_loss(pred, target, weight, reduction=self.reduction) File "/data1/lishaoxiong/sr/ESRGAN/BasicSR/basicsr/losses/loss_util.py", line 91, in wrapper loss = loss_func(pred, target, **kwargs) File "/data1/lishaoxiong/sr/ESRGAN/BasicSR/basicsr/losses/losses.py", line 16, in l1_loss return F.l1_loss(pred, target, reduction='none') File "/home/ubuntu/anaconda3/envs/pytorch1.7.1_py3.8/lib/python3.8/site-packages/torch/nn/functional.py", line 2633, in l1_loss expanded_input, expanded_target = torch.broadcast_tensors(input, target) File "/home/ubuntu/anaconda3/envs/pytorch1.7.1_py3.8/lib/python3.8/site-packages/torch/functional.py", line 71, in broadcast_tensors return _VF.broadcast_tensors(tensors) # type: ignore RuntimeError: The size of tensor a (256) must match the size of tensor b (128) at non-singleton dimension 3

xiaoxiongli avatar Dec 29 '21 07:12 xiaoxiongli

我也这个问题,我是scale为3,然后报错 The size of tensor a (168) must match the size of tensor b (128) at non-singleton dimension 3.请问怎么解决的呢?感谢感谢 @xiaoxiongli

0788945 avatar Jan 12 '24 14:01 0788945