fn
heaviside
→Tensorheaviside(x: Tensor, values: Tensor | Scalar)Heaviside step function with a user-selectable value at .
Produces 0 for negative inputs and 1 for positive inputs; the
value at exactly zero is taken from values (typically 0,
0.5, or 1 depending on convention).
Parameters
xTensorInput tensor.
valuesTensor | ScalarValue(s) used wherever
x == 0. If a scalar, it is broadcast to
the shape of x; if a tensor, it must broadcast against x.Returns
TensorElement-wise Heaviside step.
Notes
Mathematical definition:
The gradient is zero almost everywhere — the derivative is a Dirac delta in the distributional sense, which autograd does not propagate.
Examples
>>> import lucid
>>> x = lucid.tensor([-1.0, 0.0, 1.0])
>>> lucid.heaviside(x, 0.5)
Tensor([0. , 0.5, 1. ])