Feature-wise normalization of the data.
tf.keras.layers.experimental.preprocessing.Normalization( axis=-1, dtype=None, **kwargs )
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
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)>
| || Integer or tuple of integers, the axis or axes that should be "kept". These axes are not be summed over when calculating the normalization statistics. By default the last axis, the |
adapt( data, reset_state=True )
Fits the state of the preprocessing layer to the data being passed.
| ||The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array.|
| || Optional argument specifying whether to clear the state of the layer at the start of the call to |
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.