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

AttributeError: 'float' object has no attribute 'data' on pytorch 0.4.1 #8

Closed
adriangrepo opened this issue Sep 1, 2018 · 1 comment

Comments

@adriangrepo
Copy link

adriangrepo commented Sep 1, 2018

I get the following error at trainer.backward_step() on running the demo script:
File "attn2d/nmt/trainer.py", line 230, in backward_step
self.clip_norm).data.item()
AttributeError: 'float' object has no attribute 'data'

which I fixed by:
grad_norm = torch.nn.utils.clip_grad_norm_(self.model.parameters(), self.clip_norm)

Which then runs OK for torch==0.4.1

Which version of pytorch was the code written for?

@elbayadm
Copy link
Owner

elbayadm commented Sep 5, 2018

The code is written for PyTorch 0.4.0.
Your fix works fine for 0.4.0 as well.
Thanks.

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