CoNet icon indicating copy to clipboard operation
CoNet copied to clipboard

There is a difference between the target size and the input size in smooth_l1_loss

Open czq0827 opened this issue 3 years ago • 1 comments

E:\Salient Object Detection\2020ECCV\CoNet-master\CoNet\trainer.py:79: UserWarning: Using a target size (torch.Size([2, 256, 256])) that is different to the input size (torch.Size([2, 1, 256, 256])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. loss4 = F.smooth_l1_loss(high_depth, depth, reduction='sum') E:\Salient Object Detection\2020ECCV\CoNet-master\CoNet\trainer.py:81: UserWarning: Using a target size (torch.Size([2, 256, 256])) that is different to the input size (torch.Size([2, 1, 256, 256])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. loss6 = F.smooth_l1_loss(pred_depth, depth, reduction='sum')

How to solve the problem during training. Thank you very much for your reply

czq0827 avatar Apr 28 '21 08:04 czq0827

Thanks for your interest in our work. A easy way can address this problem. For target, you can add this code 'target = target.unsqueeze(1)', where [2, 256, 256] -> [2, 1, 256, 256].

jiwei0921 avatar May 01 '21 12:05 jiwei0921