Returns the mean value of all elements in the x tensor.

tch_mean(x, dim = NULL, keepdim = FALSE)

Arguments

x

tensor object

dim

the dimension to reduce

keepdim

whether the output tensor has dim retained or not. (ignored if dim is NULL)

Examples

x <- tensor(runif(100)) tch_mean(x)
#> tensor #> 0.493348 #> [ Variable[CPUFloatType]{} ]