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: expected backend CPU and dtype Float but got backend CPU and dtype Long #52

Open
PRAYALANKAR opened this issue Jun 10, 2019 · 3 comments

Comments

@PRAYALANKAR
Copy link

File "torchcv-master/examples/fpnssd/train.py", line 37, in
box_coder = FPNSSDBoxCoder()
File "/torchcv-master/torchcv/models/fpnssd/box_coder.py", line 15, in init
self.anchor_boxes = self._get_anchor_boxes(input_size=torch.tensor([512.,512.]))
File "torchcv-master/torchcv/models/fpnssd/box_coder.py", line 57, in _get_anchor_boxes
xy = (xy * grid_size)
RuntimeError: expected backend CPU and dtype Float but got backend CPU and dtype Long
i am getting this any suggestion or anyone faced the issue and solved it.

@kritiksoman
Copy link

I am also having the same issue.

@PRAYALANKAR
Copy link
Author

Hi
I solved the issue by making the following changes.
in meshgrid.py make following changes into the meshgrid function so that return value of the function is also float.
def meshgrid(x, y, row_major=True):
aa = x * 1.
bb = y * 1.
a = torch.arange(0,aa)
b = torch.arange(0,bb)
xx = a.repeat(y).view(-1,1)
yy = b.view(-1,1).repeat(1,x).view(-1,1)
return torch.cat([xx,yy],1) if row_major else torch.cat([yy,xx],1)

@deepzlk
Copy link

deepzlk commented Jul 22, 2019

grid_size=grid_size.long()
floattensor->longtensor

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

3 participants