From the documentation of tf.keras.layers.experimental.preprocessing.Normalization
:
What happens in adapt: Compute mean and variance of the data and store them as the layer’s weights. adapt should be called before fit, evaluate, or predict.
As one can imagine when dealing with large datasets, figuring out how to properly use and call the adapt()
is not clear. The tutorial below might be useful here:
From the tutorial:
norm_layer = preprocessing.Normalization()
norm_layer.adapt(spectrogram_ds.map(lambda x, _: x))
spectrogram_ds
returns tuples containing (spectrogram, label_id)
.