# heaviside¶

paddle. heaviside ( x, y, name=None ) [source]

Computes the Heaviside step function determined by corresponding element in y for each element in x. The equation is

$\begin{split}heaviside(x, y)= \left\{ \begin{array}{lcl} 0,& &\text{if} \ x < 0, \\ y,& &\text{if} \ x = 0, \\ 1,& &\text{if} \ x > 0. \end{array} \right.\end{split}$

Note

paddle.heaviside supports broadcasting. If you want know more about broadcasting, please refer to user_guide_broadcasting.

Parameters
• x (Tensor) – The input tensor of Heaviside step function, it’s data type should be float16, float32, float64, int32 or int64.

• y (Tensor) – The tensor that determines a Heaviside step function, it’s data type should be float16, float32, float64, int32 or int64.

• name (str, optional) – Name for the operation (optional, default is None). Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

N-D Tensor. A location into which the result is stored. If x and y have different shapes and are broadcastable, the resulting tensor shape is the shape of x and y after broadcasting. If x, y have the same shape, its shape is the same as x and y.

Examples

import paddle