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

change loss.numpy()[0] to float(loss) to adapt 0D #51

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Jan 17, 2023

loss正确的语义为0D Tensor,其shape为[],当前使用了shape为[1]替代,也就是向量Tensor:

在进行升级为0D后,loss.numpy()[0] 的写法不再使用,将其改变为 float(loss) 的写法,在升级前(shape为[1])、升级后(shape为[])下都同样适用,兼容改法。

@zhangyimi zhangyimi merged commit f0cc490 into PaddlePaddle:main Jan 18, 2023
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

Successfully merging this pull request may close these issues.

2 participants