Reputation: 265
I use
layers.Normalization()
in Keras, in keras.Sequential
When I try to run it, I get the following error:
module 'tensorflow.keras.layers' has no attribute 'Normalization'
I've seen the command layers.Normalization()
being used in many codes, so I don't know what's wrong. Did something change?
Upvotes: 9
Views: 22068
Reputation: 181
One reason can be that you are using the tensorflow version older then the required to use that layer. There are two ways to get around this problem.
tf.keras.layers.experimental.preprocessing.Normalization
Regards
Upvotes: 16
Reputation: 141
Check the version of TensorFlow you have:
import tensorflow as tf
print(tf.__version__)
tf.keras.layers.Normalization
is an attribute in TensorFlow v2.6.0, so might not work on earlier versions: https://www.tensorflow.org/api_docs/python/tf/keras/layers/Normalization
If you have an earlier version, you can upgrade using
pip install --upgrade tensorflow
Upvotes: 5