# tensorplay.functional.heaviside Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.heaviside.html ```python tensorplay.functional.heaviside(input, values, *, out=None) → Tensor ``` Computes the Heaviside step function for each element in input. The Heaviside step function is defined as: $$\begin{split}\text{{heaviside}}(input, values) = \begin{cases} 0, & \text{if input < 0}\\ values, & \text{if input == 0}\\ 1, & \text{if input > 0} \end{cases}\end{split}$$ Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. - values ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – The values to use where input is zero. Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> input = tensorplay.tensor([-1.5, 0, 2.0]) >>> values = tensorplay.tensor([0.5]) >>> tensorplay.heaviside(input, values) tensor([0.0000, 0.5000, 1.0000]) >>> values = tensorplay.tensor([1.2, -2.0, 3.5]) >>> tensorplay.heaviside(input, values) tensor([0., -2., 1.]) ```