|View source on GitHub|
Feature-wise normalization of the data.
See Migration guide for more details.
tf.keras.layers.Normalization( axis=-1, mean=None, variance=None, **kwargs )
Used in the notebooks
|Used in the guide||Used in the tutorials|
This layer will coerce its inputs into a distribution centered around
0 with standard deviation 1. It accomplishes this by precomputing the mean and
variance of the data, and calling
(input - mean) / sqrt(var) at runtime.
What happens in
adapt(): Compute mean and variance of the data and store
them as the layer's weights.
adapt() should be called before
Integer, tuple of integers, or None. The axis or axes that should
have a separate mean and variance for each index in the shape. For
example, if shape is
The mean value(s) to use during normalization. The passed value(s)
will be broadcast to the shape of the kept axes above; if the value(s)
cannot be broadcast, an error will be raised when this layer's
The variance value(s) to use during normalization. The passed
value(s) will be broadcast to the shape of the kept axes above; if the
value(s) cannot be broadcast, an error will be raised when this layer's
Calculate a global mean and variance by analyzing the dataset in
adapt_data = np.array([1., 2., 3., 4., 5.], dtype='float32')
input_data = np.array([1., 2., 3.], dtype='float32')
layer = tf.keras.layers.Normalization(axis=None)