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

RuntimeError: "bitwise_and_cpu" not implemented for 'Float' in DiceLoss #23

Open
agrizzli opened this issue Aug 3, 2022 · 1 comment

Comments

@agrizzli
Copy link

agrizzli commented Aug 3, 2022

I am using:

  • Python 3.8.10
  • torch 1.12.0+cu113

When setting alpha > 0 in DiceLoss it results in following error:

RuntimeError: "bitwise_and_cpu" not implemented for 'Float' in DiceLoss

at line:

https://github.com/ShannonAI/dice_loss_for_NLP/blob/master/loss/dice_loss.py#L120

This is due to wrong operator evaluation order. First & is evaluated, which is wrong. You can avoid it by adding brackets around boolean operations:

cond = ((torch.argmax(flat_input, dim=1) == label_idx) & (flat_input[:, label_idx] >= threshold)) | pos_example.view(-1)

@sfdeggb
Copy link

sfdeggb commented Apr 3, 2023

I also meet this problem!, it is so hard to slove!

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