fn

multiply

Tensor
multiply(a: Tensor, b: Tensor | Scalar)
source

Element-wise product.

Verbose alias of the * operator. Broadcasts a and b and applies the standard dtype-promotion rules.

Parameters

aTensor
First operand.
bTensor | Scalar
Second operand.

Returns

Tensor

Element-wise product of the broadcast shape of a and b.

Notes

Mathematical definition:

outi=aibi\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.])