Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get error: module 'tensorflow.keras.layers' has no attribute 'Normalization'

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?

like image 691
TheQuantumMan Avatar asked May 10 '26 08:05

TheQuantumMan


2 Answers

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.

  1. Upgrade tensorflow as discussed above.
  2. Or you can add the layer as follows:
tf.keras.layers.experimental.preprocessing.Normalization

Regards

like image 170
Ramesh Kumar Avatar answered May 13 '26 07:05

Ramesh Kumar


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
like image 20
politecat314 Avatar answered May 13 '26 06:05

politecat314



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!