You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.ops.L2Normalize.rst 1.3 kB

4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334
  1. mindspore.ops.L2Normalize
  2. ==========================
  3. .. py:class:: mindspore.ops.L2Normalize(axis=0, epsilon=1e-4)
  4. L2范数归一化算子。
  5. 该算子将对输入 `x` 在给定 `axis` 上的元素进行归一化。函数定义如下:
  6. .. math::
  7. \displaylines{{\text{output} = \frac{x}{\sqrt{\text{max}( \sum_{i}^{}\left | x_i \right | ^2, \epsilon)}}}}
  8. 其中 :math:`\epsilon` 表示 `epsilon` , :math:`\sum_{i}^{}\left | x_i \right | ^2` 表示计算输入 `x` 在给定 `axis` 上元素的平方和。
  9. **参数:**
  10. - **axis** (Union[list(int), tuple(int), int]):指定计算L2范数的轴。默认值:0。
  11. - **epsilon** (float):为了数值稳定性而引入的很小的浮点数。默认值:1e-4。
  12. **输入:**
  13. **x** (Tensor) - 计算归一化的输入。shape为 :math:`(N, *)` ,其中 :math:`*` 表示任意的附加维度数。数据类型必须为float16或float32。
  14. **输出:**
  15. Tensor,shape和数据类型与 `x` 的相同。
  16. **异常:**
  17. - **TypeError** - `axis` 不是list、tuple或int。
  18. - **TypeError** - `epsilon` 不是float。
  19. - **TypeError** - `x` 不是Tensor。
  20. - **TypeError** - `x` 的数据类型既不是float16也不是float32。
  21. - **ValueError** - `x` 的维度不大于0。