Closed zshuxin1113 closed 2 years ago
I don't have any errors when I installed tensorflow 2.4.0 from scratch and I run the import.
Can you double-check?
virtualenv venv # created virtual environment CPython3.8.0.final.0-64 in 101ms
source venv/bin/activate
pip install tensorflow==2.4.0
pip list # tensorflow 2.4.0
python -c 'from tensorflow.python.keras.layers.normalization import LayerNormalization'
2022-01-20 07:33:43.902253: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /usr/local/lib/:/usr/local/cuda-10.1/lib64/:
2022-01-20 07:33:43.902272: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Try to run:
python -c 'from tensorflow.keras.layers import LayerNormalization'
where python is the interpreter of your virtual environment
But my guess is
keras-tcn
It should work. The CI works well with TF2.4,2.5,2.6,2.7,2.8.
Let me know if you need more help. I'll close this issue for now.
Could you please help me?
Describe the bug ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization'
Paste a snippet Traceback (most recent call last): File "test_tcn.py", line 1, in
from tcn import TCN, tcn_full_summary
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tcn/init.py", line 1, in
from tcn.tcn import TCN, compiled_tcn, tcn_full_summary # noqa
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tcn/tcn.py", line 4, in
from tensorflow.keras import backend as K, Model, Input, optimizers
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/init.py", line 41, in
from tensorflow.python.tools import module_util as _module_util
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/python/init.py", line 48, in
from tensorflow.python import keras
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/python/keras/init.py", line 27, in
from tensorflow.python.keras import models
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/python/keras/models.py", line 27, in
from tensorflow.python.keras.engine import sequential
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/python/keras/engine/sequential.py", line 28, in
from tensorflow.python.keras import layers as layer_module
File "/common/home/sz517/.conda/envs/scooter/lib/python3.8/site-packages/tensorflow/python/keras/layers/init.py", line 177, in
from tensorflow.python.keras.layers.normalization import LayerNormalization
ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization'
Dependencies Tensorflow == 2.4.0
Thanks for your help!