Skip to contents

Computes the arithmetic mean along the specified dimensions.

Usage

nv_reduce_mean(operand, dims, drop = TRUE)

Arguments

operand

(tensorish)
Operand.

dims

(integer())
Dimensions to reduce.

drop

(logical(1))
Whether to drop reduced dimensions.

Value

tensorish
Has the same data type as the input. When drop = TRUE, the reduced dimensions are removed. When drop = FALSE, the reduced dimensions are set to 1.

Details

Implemented as nv_reduce_sum(operand, dims, drop) / n where n is the product of the reduced dimension sizes.

See also

Examples

jit_eval({
  x <- nv_tensor(matrix(1:6, nrow = 2))
  nv_reduce_mean(x, dims = 1L)
})
#> AnvilTensor
#>  1.5000
#>  3.5000
#>  5.5000
#> [ CPUf32?{3} ]