optimizes the documentation of chinese API of ClipByNorm.

This commit is contained in:
zhangfanghe 2022-03-02 15:36:24 +08:00
parent 5b360e39fb
commit 59ef2eb8e4
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
mindspore.nn.ClipByNorm
========================
.. py:function:: mindspore.nn.ClipByNorm(axis=None)
对输入Tensor的值进行裁剪使用 :math:`L_2` 范数控制梯度。
如果输入Tensor的 :math:`L_2` 范数不大于输入 `clip_norm` ,则此层的输出保持不变。
否则Tensor将标准化为
.. math::
\text{output}(X) = \frac{\text{clip_norm} * X}{L_2(X)},
其中 :math:`L_2(X)`:math:`X`:math:`L_2` 范数。
**参数:**
- **axis** (Union[None, int, tuple(int)]) - 指定在哪个维度上计算 :math:`L_2` 范数。如果为None则计算所有维度。默认值None。
**输入:**
- **x** (Tensor) - 输入n维的Tensor数据类型为float32或float16。
- **clip_norm** (Tensor) - shape为 :math:`()`:math:`(1)` 的Tensor。或者Tensor的shape可以广播到输入的shape。
**输出:**
Tensor裁剪后的Tensor与输入 `x` 的shape相同数据类型为float32。
**异常:**
- **TypeError** - `axis` 不是None、int、或tuple。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。