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.heavisidesupports 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 x = paddle.to_tensor([-0.5, 0, 0.5]) y = paddle.to_tensor([0.1]) paddle.heaviside(x, y) # [0. , 0.10000000, 1. ] x = paddle.to_tensor([[-0.5, 0, 0.5], [-0.5, 0.5, 0]]) y = paddle.to_tensor([0.1, 0.2, 0.3]) paddle.heaviside(x, y) # [[0. , 0.20000000, 1. ], # [0. , 1. , 0.30000001]] 
