fn
prod
→Tensorprod(x: Tensor, dim: _int | list[_int] | None = None, keepdim: _bool = False)Compute the product of elements along dim.
The multiplicative analogue of sum. Reducing along dim
produces a tensor whose entries equal the product of all values that
were collapsed.
Parameters
xTensorInput tensor.
dimint or list of int= NoneDimension(s) to reduce.
None reduces over the whole tensor.keepdimbool= FalseKeep reduced dims with size 1.
Returns
TensorReduced tensor.
Notes
For numerical reasons, products of many small values are better
computed via exp(sum(log(x))).
Examples
>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0, 4.0])
>>> lucid.prod(x)
Tensor(24.)