ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.no rmalization'

Viewed 3560

In running a python project I get the following error. I installed various versions of tensorflow (from 2.2.3 to 2.4.1), but the problem is there... I don't know what I should change or what is the mismatch. It previously was working... please help if you know tensroflow

File "/home/pouramini/seqio/seqio/utils.py", line 25, in <module>
    import tensorflow.compat.v2 as tf
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/__init__.py", line
 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/__init__.py
", line 84, in <module>
    from tensorflow.python import keras
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/keras/__in$
t__.py", line 27, in <module>
    from tensorflow.python.keras import models
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/keras/mode$
s.py", line 27, in <module>
    from tensorflow.python.keras.engine import sequential
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/keras/engi$
e/sequential.py", line 24, in <module>
   from tensorflow.python.keras import layers as layer_module
  File "/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/keras/layer
s/__init__.py", line 149, in <module>
    from tensorflow.python.keras.layers.normalization import LayerNormalization
ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.no
rmalization' (/home/pouramini/miniconda3/lib/python3.7/site-packages/tensorflow/python/keras
/layers/normalization/__init__.py)

1 Answers

I uninstalled tensorflow both by conda remove tensorflow and pip uninstall tensorflow and even removed the folder manually from miniconda3/lib/python3.7/site-packages/

Then installed tensorflow (I tried 2.3.0) by pip install tensorflow==2.3.0

now the problem was resolved

Related