tf.keras.layers.experimental.preprocessing.Normalization( axis=-1, dtype=None, **kwargs )
Feature-wise normalization of the data.
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
featuresaxis is kept and any
timeaxes are summed. Each element in the the axes that are kept is normalized independently. If
axisis set to 'None', the layer will perform scalar normalization (diving the input by a single scalar value). The
batchaxis, 0, is always summed over (
axis=0is not allowed).
Calculate the mean and variance by analyzing the dataset in
>>> adapt_data = np.array([[1.], [2.], [3.], [4.], [5.]], dtype=np.float32) >>> input_data = np.array([[1.], [2.], [3.]], np.float32) >>> layer = Normalization() >>> layer.adapt(adapt_data) >>> layer(input_data) <tf.Tensor: shape=(3, 1), dtype=float32, numpy= array([[-1.4142135 ], [-0.70710677], [ 0. ]], dtype=float32)>