在AIStUDIo中运行代码,paddle版本是2.2.0,运行环境是CPU,执行代码是:
inp = paddle.to_tensor([1], dtype='float32', stop_gradient=False)
y = paddle.sin(inp)
y_x = paddle.grad(y, inp, create_graph=True, retain_graph=True)
报错:
(NotFound) The Op sin_grad doesn't have any grad op. If you don't intend calculating higher order derivatives, please set create_graph
to False.
[Hint: double_grad_node should not be null.] (at /paddle/paddle/fluid/imperative/partial_grad_engine.cc:908)
2条答案
按热度按时间gcuhipw91#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API,FAQ,Github Issue and AI community to get the answer.Have a nice day!
7kqas0il2#
报错提示sin OP没有二阶梯度计算kernel
如果您只需要计算一阶梯度,可以设置create_graph=False