var_mean¶
dragon.vm.torch.
var_mean
(
input,
dim=None,
keepdim=False,
out=None
)[source]¶Compute the variance and mean of elements along the given dimension.
dim
could be negative orNone
:x = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.float32) # A negative dimension is the last-k dimension print(torch.var_mean(x, dim=1)) print(torch.var_mean(x, dim=-1)) # Equivalent # If dimension is None, reduce input as a vector # and return a scalar result print(torch.var_mean(x)) # (2.917, 3.5) # Also, dimension could be a sequence of integers print(torch.var_mean(x, (0, 1))) # (2.917, 3.5)
- Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- dim (Union[int, Sequence[int]], optional) – The dimension to reduce.
- keepdim (bool, optional, default=False) – Keep the reduced dimension or not.
- out (Sequence[dragon.vm.torch.Tensor], optional) – The optional output value and index.
- Returns:
Sequence[dragon.vm.torch.Tensor] – The variance and mean tensor.