Skip to content
fn

multiply

→Tensor
multiply(input: Tensor, other: Tensor | Scalar)

Element-wise product.

Verbose alias of the * operator. Broadcasts input and other and applies the standard dtype-promotion rules.

Parameters

inputTensor
First operand.
otherTensor | Scalar
Second operand.

Returns

Tensor

Element-wise product of the broadcast shape of input and other.

Notes

Mathematical definition:

outi=ai⋅bi\text{out}_i = a_i \cdot b_i

Gradients: ∂/∂a=b\partial / \partial a = b, ∂/∂b=a\partial / \partial b = a.

Examples

>>> import lucid
>>> a = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.multiply(a, 2.0)
tensor([2., 4., 6.])