Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using BceDiceLoss, please help me #5

Open
WangZhi-wz opened this issue Apr 21, 2022 · 1 comment
Open

Error using BceDiceLoss, please help me #5

WangZhi-wz opened this issue Apr 21, 2022 · 1 comment

Comments

@WangZhi-wz
Copy link

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
`

@ReaFly
Copy link
Owner

ReaFly commented Apr 23, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants