mindspore.ops.sgn

查看源文件
mindspore.ops.sgn(input)[源代码]

mindspore.ops.sign() 在复数上的扩展。 对于实数输入,此方法与 mindspore.ops.sign() 一致。 对于复数输入,此方法按照如下公式计算:

outi={0|inputi|==0inputi|inputi|otherwise
参数:
  • input (Tensor) - 输入tensor。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> 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  ]]