diff --git a/tutorials/source_en/advanced_use/debugging_in_pynative_mode.md b/tutorials/source_en/advanced_use/debugging_in_pynative_mode.md index 1142684a4ef8d9f5b052995d07280ac6c9c7d00d..e1a0ca07a2ef05e6b87028fb98d6817379981cfe 100644 --- a/tutorials/source_en/advanced_use/debugging_in_pynative_mode.md +++ b/tutorials/source_en/advanced_use/debugging_in_pynative_mode.md @@ -243,7 +243,7 @@ print(z.asnumpy()) ## Debugging Network Train Model -In PyNative mode, the gradient can be calculated separately. As shown in the following example, `GradOperation` is used to calculate all input gradients of the function or the network. +In PyNative mode, the gradient can be calculated separately. As shown in the following example, `GradOperation` is used to calculate all input gradients of the function or the network. Note that the inputs have to be Tensor. **Example Code** @@ -259,7 +259,7 @@ def mul(x, y): def mainf(x, y): return C.GradOperation('get_all', get_all=True)(mul)(x, y) -print(mainf(1,2)) +print(mainf(Tensor(1, mstype.int32), Tensor(2, mstype.int32))) ``` **Output** diff --git a/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md b/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md index 4ab62931237f86a53455adfe30cf48accaf28103..ba3ea2089a3e2cffe86de8e89fa92a18b08a2767 100644 --- a/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md +++ b/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md @@ -245,7 +245,7 @@ print(z.asnumpy()) ## 调试网络训练模型 -PyNative模式下,还可以支持单独求梯度的操作。如下例所示,可通过`GradOperation`求该函数或者网络所有的输入梯度。 +PyNative模式下,还可以支持单独求梯度的操作。如下例所示,可通过`GradOperation`求该函数或者网络所有的输入梯度。需要注意,输入类型仅支持Tensor。 **示例代码** @@ -261,7 +261,7 @@ def mul(x, y): def mainf(x, y): return C.GradOperation('get_all', get_all=True)(mul)(x, y) -print(mainf(1,2)) +print(mainf(Tensor(1, mstype.int32), Tensor(2, mstype.int32))) ``` **输出**