未验证 提交 d4a97673 编写于 作者: H huangxu96 提交者: GitHub

Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into grad_doc (#29246)

上级 f5afeef1
......@@ -444,7 +444,6 @@ def grad(outputs,
.. code-block:: python
import paddle
paddle.disable_static()
def test_dygraph_grad(create_graph):
x = paddle.ones(shape=[1], dtype='float32')
......@@ -479,10 +478,9 @@ def grad(outputs,
.. code-block:: python
import paddle
paddle.disable_static()
def test_dygraph_grad(grad_outputs=None):
x = paddle.fluid.layers.fill_constant(shape=[1], value=2.0, dtype='float32')
x = paddle.to_tensor(2.0)
x.stop_gradient = False
y1 = x * x
......@@ -505,8 +503,7 @@ def grad(outputs,
return dx.numpy()
grad_value = paddle.fluid.layers.fill_constant(shape=[1], value=4.0, dtype='float32')
grad_value = paddle.to_tensor(4.0)
# dy1 = [1], dy2 = [1]
print(test_dygraph_grad(None)) # [7.]
......@@ -517,7 +514,7 @@ def grad(outputs,
print(test_dygraph_grad([grad_value, None])) # [19.]
# dy1 = [3], dy2 = [4]
grad_y1 = paddle.fluid.layers.fill_constant(shape=[1], value=3.0, dtype='float32')
grad_y1 = paddle.to_tensor(3.0)
print(test_dygraph_grad([grad_y1, grad_value])) # [24.]
'''
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册