torch.mean(dim=k) — rank ≤ 3

This interactive demo helps you visualize how torch.mean() computes the mean value of all elements in the input tensor. You can enter rank-1, rank-2 or rank-3 tensors and hover over input or output elements to see which input values are averaged together to produce each output value.

Shape (rank 1–3) Reduce dim
Expression
Hover a cell in input or output.
(expression will appear here)
Input tensor x
shape = …
Output tensor y = mean(x, dim=…)
shape = …