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

如何处理的student多次forward 的loss #239

Open
Whale-ice opened this issue Jul 8, 2023 · 2 comments
Open

如何处理的student多次forward 的loss #239

Whale-ice opened this issue Jul 8, 2023 · 2 comments

Comments

@Whale-ice
Copy link

您好,请问代码中student model对于有标签书先进行了forwardtrain得到了losses,对于无标签数据又单独进行了forwardtrain,这样两次forward不会导致student网络中同一个参数点在计算图中被标记了两次,会导致loss.backward报错吗?

@Fengzeheng
Copy link

两次forwardtrain只是得到的loss值不同,但每个网络参数tensor中记录的运算操作相同(记录在grad_fn中?),或者说两次产生的计算图的全局拓扑一致,所以叠加后backward没问题。

@Whale-ice
Copy link
Author

谢谢你回答,两次计算图确实是拓扑一致的,不应该报错,我是使用了checkpoint机制才导致的这个问题,关掉以后就不会报错了。

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