From f981e773f51d5d9c3d7eed96ff57853b427926b9 Mon Sep 17 00:00:00 2001 From: gongchen Date: Wed, 27 May 2020 16:33:38 +0800 Subject: [PATCH] Change C.grad_with_sens. --- tutorials/source_zh_cn/use/custom_operator.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tutorials/source_zh_cn/use/custom_operator.md b/tutorials/source_zh_cn/use/custom_operator.md index be67329e..18004d1f 100644 --- a/tutorials/source_zh_cn/use/custom_operator.md +++ b/tutorials/source_zh_cn/use/custom_operator.md @@ -223,14 +223,15 @@ class CusSquare(PrimitiveWithInfer): return bprop ``` -在`test_square.py`文件中定义反向用例。其中,`grad_with_sens`是`GradOperation`类的实例化对象。 +在`test_square.py`文件中定义反向用例。 ```python from mindspore.ops import composite as C def test_grad_net(): x = np.array([1.0, 4.0, 9.0]).astype(np.float32) sens = np.array([1.0, 1.0, 1.0]).astype(np.float32) square = Net() - dx = C.grad_with_sens(square)(Tensor(x), Tensor(sens)) + grad = C.GradOperation('grad_with_sens', sens_param=True) + dx = grad(square)(Tensor(x), Tensor(sens)) print("x: ", x) print("dx: ", dx) ``` -- GitLab