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

第三章 Tensor和autograd第90页代码bug #217

Open
Gamkiu opened this issue Jul 31, 2020 · 1 comment
Open

第三章 Tensor和autograd第90页代码bug #217

Gamkiu opened this issue Jul 31, 2020 · 1 comment

Comments

@Gamkiu
Copy link

Gamkiu commented Jul 31, 2020

文章代码运行错误,(第三段代码)
x = V(t.arange(-2,4),requires_grad = True).
运行时出现“only Tensor of floating point type can require grad.”错误

@Monkey-D-Luffy-star
Copy link

改成t.arange(-2,4).float()就可以了
老版本的pytorch用arange创建默认是FloatTensor类型的
新版本arange创建时dtype默认是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

2 participants