fn
mean
→Tensormean(x: Tensor, dim: _int | list[_int] | None = None, keepdim: _bool = False)Compute the arithmetic mean along dim.
The sample mean of n values is
Floating-point results are accumulated in the same dtype as the input; integer inputs are promoted to the default floating dtype before the reduction is performed.
Parameters
xTensorInput tensor.
dimint or list of int= NoneDimension(s) to reduce.
None reduces over all elements.keepdimbool= FalseWhether to retain the reduced dim(s) with size 1.
Returns
TensorReduced tensor of floating dtype.
Notes
Mean is an unbiased estimator of the population mean. For empty
reductions (size-0 dim) the result is nan.
Examples
>>> import lucid
>>> x = lucid.tensor([[1.0, 2.0], [3.0, 4.0]])
>>> lucid.mean(x)
Tensor(2.5)
>>> lucid.mean(x, dim=0)
Tensor([2., 3.])