oneflow.sign¶
-
oneflow.
sign
()¶ Computes the sign of Tensor.
\[\text{out}_{i} = \text{sgn}(\text{input}_{i})\]- Parameters
input (Tensor) – the input tensor.
For example:
>>> import oneflow as flow >>> import numpy as np >>> x1 = flow.tensor(np.array([-2, 0, 2]).astype(np.float32)) >>> out1 = flow.sign(x1) >>> out1.numpy() array([-1., 0., 1.], dtype=float32) >>> x2 = flow.tensor(np.array([-3.2, -4.5, 5.8]).astype(np.float32),device=flow.device('cuda')) >>> out2 = flow.sign(x2) >>> out2.numpy() array([-1., -1., 1.], dtype=float32)