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

第五章 rnn用于时间序列的分析 #32

Open
WenbinSun opened this issue Mar 13, 2019 · 2 comments
Open

第五章 rnn用于时间序列的分析 #32

WenbinSun opened this issue Mar 13, 2019 · 2 comments

Comments

@WenbinSun
Copy link

WenbinSun commented Mar 13, 2019

请问老师这个问题怎么解决觉得?

if (e + 1) % 100 == 0: # 每 100 次输出结果
---> 12 print('Epoch: {}, Loss: {:.5f}'.format(e + 1, loss.data[0]))

IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

@L1aoXingyu
Copy link
Owner

把 loss.data[0] 改成 loss.item() 就可以了,这是版本不一致的问题

@WenbinSun
Copy link
Author

把 loss.data[0] 改成 loss.item() 就可以了,这是版本不一致的问题

谢谢老师。

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