提交 ae311a22 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!389 Modify the tutorial example: GradOperation only support tensor

Merge pull request !389 from Simson/master
......@@ -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**
......
......@@ -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)))
```
**输出**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册