Mean of a tensor, alongside the specified axis. Arguments: x: A tensor or variable. axis: A list of integer. Axes to compute the mean. keepdims: A boolean, whether to keep the dimensions or not. If `keepdims` is `False`, the rank of the tensor is reduced by 1
(x, axis=None, keepdims=False)
| 1985 | |
| 1986 | @keras_export('keras.backend.mean') |
| 1987 | def mean(x, axis=None, keepdims=False): |
| 1988 | """Mean of a tensor, alongside the specified axis. |
| 1989 | |
| 1990 | Arguments: |
| 1991 | x: A tensor or variable. |
| 1992 | axis: A list of integer. Axes to compute the mean. |
| 1993 | keepdims: A boolean, whether to keep the dimensions or not. |
| 1994 | If `keepdims` is `False`, the rank of the tensor is reduced |
| 1995 | by 1 for each entry in `axis`. If `keepdims` is `True`, |
| 1996 | the reduced dimensions are retained with length 1. |
| 1997 | |
| 1998 | Returns: |
| 1999 | A tensor with the mean of elements of `x`. |
| 2000 | """ |
| 2001 | if x.dtype.base_dtype == dtypes_module.bool: |
| 2002 | x = math_ops.cast(x, floatx()) |
| 2003 | return math_ops.reduce_mean(x, axis, keepdims) |
| 2004 | |
| 2005 | |
| 2006 | @keras_export('keras.backend.any') |