You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import paddle
a = paddle.ones([100])
a.stop_gradient = False
b = paddle.ones([100])
b.stop_gradient = False
c = a + b
d = c + c
e = d + d
# paddle_out_grads = paddle.autograd.backward([e], [paddle.ones([100])]) # rigth
paddle_out_grads = paddle.autograd.backward([e,c,d], [paddle.ones([100]),paddle.ones([100]),paddle.ones([100])])
报错内容为:
Traceback (most recent call last):
File "/host_home/wanghuan29/Paddle/test_grad.py", line 13, in <module>
paddle_out_grads = paddle.autograd.backward([e,c,d], [paddle.ones([100]),paddle.ones([100]),paddle.ones([100])])
File "/usr/local/lib/python3.9/dist-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/host_home/wanghuan29/Paddle2/build/python/paddle/base/wrapped_decorator.py", line 40, in __impl__
return wrapped_func(*args, **kwargs)
File "/host_home/wanghuan29/Paddle2/build/python/paddle/base/framework.py", line 726, in __impl__
return func(*args, **kwargs)
File "/host_home/wanghuan29/Paddle2/build/python/paddle/autograd/backward_mode.py", line 140, in backward
core.eager.run_backward(tensors, grad_tensors, retain_graph)
SystemError: (Fatal) Unable to find next node in the GradTensorHolder
Trying to run Node without configuring its GradTensorHolder.
[Hint: Expected node_input_buffer_iter != node_input_buffers_dict.end(), but received node_input_buffer_iter == node_input_buffers_dict.end().] (at /host_home/wanghuan29/Paddle2/paddle/fluid/eager/backward.cc:272)
如下代码有同样的问题:
import paddle
a = paddle.ones([100])
a.stop_gradient = False
b = paddle.ones([100])
b.stop_gradient = False
c = a + b
d = c + c
e = d + d
f, g = paddle.split(e, num_or_sections=2, axis=0)
h = f + f
paddle_out_grads = paddle.autograd.backward([h,g], [paddle.ones([50]),paddle.ones([50])])
你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册。
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Execute Infrastructure
PR Types
Improvements
Description
Paddle 对于如下代码会报错:
报错内容为:
如下代码有同样的问题:
第一种情况,用户提供了c和d的梯度,那么通过反向回传获得的梯度该怎么办。实测torch.autograd.grad和paddle.grad都是将用户提供的梯度以及回传算出的梯度加和。因此,paddle.autograd.backward也有必要这么做。
第二种情况,是paddle.autograd.backward存在bug。
这两种错误在paddle.autograd.backward时会发生,在paddle.grad时不会发生,因为paddle.grad会走PreparedForGeneralGrad,对反向图做剪枝等优化。
Pcard-67164