tf.keras.ops.moments
Calculates the mean and variance of x
.
tf.keras.ops.moments(
x, axes, keepdims=False, synchronized=False
)
The mean and variance are calculated by aggregating the contents of x
across axes
. If x
is 1-D and axes = [0]
this is just the mean and
variance of a vector.
Args |
x
|
Input tensor.
|
axes
|
A list of axes which to compute mean and variance.
|
keepdims
|
If this is set to True , the axes which are reduced are left
in the result as dimensions with size one.
|
synchronized
|
Only applicable with the TensorFlow backend.
If True , synchronizes the global batch statistics (mean and
variance) across all devices at each training step in a
distributed training strategy. If False , each replica uses its own
local batch statistics.
|
Returns |
A tuple containing two tensors - mean and variance.
|
Example:
x = keras.ops.convert_to_tensor([0, 1, 2, 3, 100], dtype="float32")
keras.ops.moments(x, axes=[0])
(array(21.2, dtype=float32), array(1553.3601, dtype=float32))
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-06-07 UTC.
[null,null,["Last updated 2024-06-07 UTC."],[],[]]