ZFTurbo/classification_models_3D

ImportError: cannot import name 'VersionAwareLayers' from 'keras.layers'

nasir3843 opened this issue · 6 comments

Thank you for the great work.

I am experiencing the following error over and over, even though I created a brand new tensorflow environment and installed all the necessary libraries in it. Could you please have a look on it and guide me how do I solve this problem? Thank you.

ImportError: Unable to import 'VersionAwareLayers' from 'keras.layers' (/home/ubuntu/anaconda3/envs/cm_3d/lib/python3.7/site-packages/keras/layers/init.py)

I experienced the same thing. Have you found any solution? Is it due to tensorflow or keras version?

Sorry, I don't exactly remember what worked for me that time but I managed to solve this problem. If you prefer, you can create conda enviroment same as mine using .yaml file of my working environment. This will install required versions of tensorflow and keras libraries for you.

.yaml file : https://drive.google.com/file/d/1TGsXzsncMlZsaGxg3dwKK_JG5tQLkG0P/view
conda commad : conda env create -f [path to .yaml file]

Right, it seems due to the tensorflow and Keras version. I tried to search for this issue on ChatGPT and here is what I got:

It looks like you are trying to import a module or class called VersionAwareLayers from the keras.layers module, but you are unable to do so.

Here are a few things you can try:

Make sure that you have installed the latest version of Keras, as the VersionAwareLayers class may have been added in a recent version.
Check the spelling of the class name to make sure it is correct.
Make sure that you are using the correct import statement. The correct import statement for the VersionAwareLayers class would be from keras.layers import VersionAwareLayers.
If you are using a version of Keras that is older than 2.4, it is possible that the VersionAwareLayers class does not exist in that version. In this case, you will need to upgrade to a newer version of Keras in order to use this class.
I hope this helps! Let me know if you have any other questions or if there is anything else I can do to help.

If you find the working versions of tensorflow and keras I will add it in requirements. I think there were some critical changes in latest tensorflow.

@ZFTurbo For me, it finally worked with Tensorflow 2.9.0 and Keras 2.9.0

@ZFTurbo Tensorflow 2.9.0 and Keras 2.9.0 worked for me as well