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

LCC and SSIM loss function error #28

Open
wpstephen opened this issue Apr 23, 2020 · 7 comments
Open

LCC and SSIM loss function error #28

wpstephen opened this issue Apr 23, 2020 · 7 comments

Comments

@wpstephen
Copy link

I am trying to do some Rigid Registration on binary images of size 64x64 and I was playing around with different loss functions. But while trying to use both LCC and SSIM loss functions, I got following error:
RuntimeError: Subtraction, the - operator, with a bool tensor is not supported. If you are trying to invert a mask, use the ~ or logical_not() operator instead.

I am not quite sure what this error entails, could anyone assist me here?

@RobinSandkuehler
Copy link
Collaborator

Hi,

I think this is versioning issue with PyTorch. We work on it in order to support the newest PyTorch version.

@wpstephen
Copy link
Author

wpstephen commented Apr 23, 2020 via email

@RobinSandkuehler
Copy link
Collaborator

Yes, Try Version 1.3 or below

@wpstephen
Copy link
Author

wpstephen commented Apr 25, 2020

@RobinSandkuehler I tried on torch verson 1.3 and 1.2 but both produced another error:

RuntimeError: expected device cpu and dtype Byte but got device cpu and dtype Bool

I tried figuring out why dtype is set to Bool, but I cannot seem to figure out why it is happening

@jlevy44
Copy link

jlevy44 commented Apr 27, 2020

@sumanthratna

@mysakbm
Copy link

mysakbm commented Jul 20, 2022

The issue is that the mask is a boolean tensor. In the code on line 267, there is "mask = 1-mask" which is not supported by torch. You need to convert the mask into array of ints:
mask = 1 - mask.type(th.uint8)

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

4 participants