mindspore/docs/api/api_python/ops/mindspore.ops.func_sgn.rst

23 lines
684 B
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.sgn
==================
.. py:function:: mindspore.ops.sgn(x)
:func:`mindspore.ops.sign` 在复数上的扩展。
对于实数输入,此方法与 :func:`mindspore.ops.sign` 一致。
对于复数输入,此方法按照如下公式计算。
.. math::
\text{out}_{i} = \begin{cases}
0 & |\text{x}_i| == 0 \\
\frac{{\text{x}_i}}{|{\text{x}_i}|} & \text{otherwise}
\end{cases}
参数:
- **x** (Tensor) - 输入Tensor。
返回:
Tensor `x` 的sgn计算结果。
异常:
- **TypeError** - 如果 `x` 不是Tensor。