mindspore.ops.heaviside
- mindspore.ops.heaviside(x, values)[source]
Computes the Heaviside step function for each element in input.
- Parameters
- Returns
Tensor, has the same type as ‘x’ and ‘values’.
- Raises
TypeError – If x or values is not Tensor.
TypeError – If data type x and values is different.
ValueError – If shape of two inputs are not broadcastable.
- Supported Platforms:
GPU
CPU
Examples
>>> x = Tensor(np.array([-1.5, 0., 2.])) >>> values = Tensor(np.array([0.5])) >>> y = ops.heaviside(x, values) >>> print(y) [ 0. 0.5 1. ]