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

about_CC.py #6

Open
baba1587 opened this issue Dec 2, 2020 · 3 comments
Open

about_CC.py #6

baba1587 opened this issue Dec 2, 2020 · 3 comments

Comments

@baba1587
Copy link

baba1587 commented Dec 2, 2020

hello i met this problem and please u to see .
1 x = torch.randn(2,64,5,6)
2
----> 3 y = model(x)

1 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
--> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)

in forward(self, x)
24 proj_value_H = proj_value.permute(0,3,1,2).contiguous().view(m_batchsizewidth,-1,height)
25 proj_value_W = proj_value.permute(0,2,1,3).contiguous().view(m_batchsize
height,-1,width)
---> 26 energy_H = (torch.bmm(proj_query_H, proj_key_H)+self.INF(m_batchsize, height, width)).view(m_batchsize,width,height,height).permute(0,2,1,3)
27 energy_W = torch.bmm(proj_query_W, proj_key_W).view(m_batchsize,height,width,width)
28 concate = self.softmax(torch.cat([energy_H, energy_W], 3))

RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #3 'other'

@Serge-weihao
Copy link
Owner

Serge-weihao commented Dec 2, 2020

you can add x = torch.randn(2,64,5,6) -> x = torch.randn(2,64,5,6).cuda() and model = model.cuda()

@Serge-weihao
Copy link
Owner

or you can remove .cuda() in
def INF(B,H,W):
return -torch.diag(torch.tensor(float("inf")).cuda().repeat(H),0).unsqueeze(0).repeat(B*W,1,1)

@baba1587
Copy link
Author

baba1587 commented Dec 2, 2020

OK it works thank you

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