mindspore.ops.sgn

View Source On Gitee
mindspore.ops.sgn(input)[source]

Extension of mindspore.ops.sign() in complex domain. For real number input, this function is the same as mindspore.ops.sign(). For complex input, this function is calculated according to the following formula.

outi={0|inputi|==0inputi|inputi|otherwise
Parameters

input (Tensor) – The input tensor.

Returns

Tensor

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> input = mindspore.tensor([[3+4j, 7-24j, 0, 6+8j, 8], [15+20j, 7-24j, 0, 3+4j, 20]], mindspore.complex64)
>>> output = mindspore.ops.sgn(input)
>>> print(output)
[[0.6 +0.8j  0.28-0.96j 0.  +0.j   0.6 +0.8j  1.  +0.j  ]
 [0.6 +0.8j  0.28-0.96j 0.  +0.j   0.6 +0.8j  1.  +0.j  ]]