代码:
x = paddle.rand(shape=[2, 5], dtype=np.float32)
x.stop_gradient = False
u = paddle.exp(x)
du_dx = paddle.grad(u, x, create_graph=True)[0]
d2u_dx2 = paddle.grad(du_dx, x, create_graph=True)[0]
报错:
RuntimeError: (Unavailable) The Op exp_grad doesn't have any gradop. If you don't intend calculating higher orderderivatives, please set create_graphto False. (at /paddle/paddle/fluid/eager/api/generated/eager_generated/backwards/nodes.cc:8177)
代码:
x = paddle.rand(shape=[2, 5], dtype=np.float32)
x.stop_gradient = False
u = paddle.cos(x)
du_dx = paddle.grad(u, x, create_graph=True)[0]
d2u_dx2 = paddle.grad(du_dx, x, create_graph=True)[0]
报错:
RuntimeError: (NotFound) Unable to get phi::DenseTensor data of Output d2d1y in operator CosDoubleGrad. Possible reasons are:
The d2d1y is not the Output of operator CosDoubleGrad;
The d2d1y has no corresponding variable passed in;
The d2d1y corresponding variable is not initialized.
[Hint: pointer ddOut should not be null.] (at /paddle/paddle/phi/kernels/funcs/activation_functor.h:405)
请提出你的问题 Please ask your question
代码: x = paddle.rand(shape=[2, 5], dtype=np.float32) x.stop_gradient = False u = paddle.exp(x) du_dx = paddle.grad(u, x, create_graph=True)[0] d2u_dx2 = paddle.grad(du_dx, x, create_graph=True)[0] 报错: RuntimeError: (Unavailable) The Op exp_grad doesn't have any gradop. If you don't intend calculating higher orderderivatives, please set
create_graph
to False. (at /paddle/paddle/fluid/eager/api/generated/eager_generated/backwards/nodes.cc:8177)代码: x = paddle.rand(shape=[2, 5], dtype=np.float32) x.stop_gradient = False u = paddle.cos(x) du_dx = paddle.grad(u, x, create_graph=True)[0] d2u_dx2 = paddle.grad(du_dx, x, create_graph=True)[0] 报错: RuntimeError: (NotFound) Unable to get phi::DenseTensor data of Output d2d1y in operator CosDoubleGrad. Possible reasons are:
以上报错如何解决?