Please help me, I didn't change any configuration and this error occurs when I want to use BceDiceLoss in the code
`------ Epoch ------ 1
D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torchvision\transforms\functional.py:991: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum.
warnings.warn(
D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py:3631: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
warnings.warn(
0%| | 0/150 [00:03<?, ?it/s]
Traceback (most recent call last):
File "D:\paperin\Enhanced-U-Net-main\train.py", line 236, in
train()
File "D:\paperin\Enhanced-U-Net-main\train.py", line 157, in train
loss = BceDiceLoss()(output, gt)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, *kwargs)
File "D:\paperin\Enhanced-U-Net-main\utils\loss.py", line 63, in forward
fcloss = self.fl(pred, target)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(input, **kwargs)
File "D:\paperin\Enhanced-U-Net-main\utils\loss.py", line 109, in forward
ce_loss = F.binary_cross_entropy(inputs, targets, reduction=self.reduction, weight=self.weight)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 2905, in binary_cross_entropy
if target.size() != input.size():
AttributeError: 'tuple' object has no attribute 'size'
Thanks for your attention. The input of this function should be a tensor, not a tuple. You could covert the tuple to tensors and then use this function.
Please help me, I didn't change any configuration and this error occurs when I want to use BceDiceLoss in the code `------ Epoch ------ 1 D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torchvision\transforms\functional.py:991: UserWarning: Argument interpolation should be of type InterpolationMode instead of int. Please, use InterpolationMode enum. warnings.warn( D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py:3631: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. warnings.warn( 0%| | 0/150 [00:03<?, ?it/s] Traceback (most recent call last): File "D:\paperin\Enhanced-U-Net-main\train.py", line 236, in
train()
File "D:\paperin\Enhanced-U-Net-main\train.py", line 157, in train
loss = BceDiceLoss()(output, gt)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(*input, *kwargs)
File "D:\paperin\Enhanced-U-Net-main\utils\loss.py", line 63, in forward
fcloss = self.fl(pred, target)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
return forward_call(input, **kwargs)
File "D:\paperin\Enhanced-U-Net-main\utils\loss.py", line 109, in forward
ce_loss = F.binary_cross_entropy(inputs, targets, reduction=self.reduction, weight=self.weight)
File "D:\ProgramData\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\functional.py", line 2905, in binary_cross_entropy
if target.size() != input.size():
AttributeError: 'tuple' object has no attribute 'size'
Process finished with exit code 1 `