fn
rsub
→Tensorrsub(a: Tensor, b: Tensor | Scalar, alpha: float = ...)Reverse subtraction: .
Useful when b is a Python scalar that cannot left-bind the -
operator against a tensor in a particular calling convention.
Parameters
aTensorRight operand (subtrahend, multiplied by
alpha).bTensor | ScalarLeft operand (minuend).
alphafloatScalar multiplier applied to
a. Defaults to 1.0.Returns
TensorElement-wise difference of the broadcast shape of a and b.
Notes
Mathematical definition:
Equivalent to subtract with the operands reversed (and alpha
re-attached to the new second argument). Gradient w.r.t. a is
; w.r.t. b is .
Examples
>>> import lucid
>>> a = lucid.tensor([1.0, 2.0])
>>> lucid.rsub(a, 10.0)
Tensor([9., 8.])