classification_models_3D icon indicating copy to clipboard operation
classification_models_3D copied to clipboard

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

Open nasir3843 opened this issue 2 years ago • 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)

nasir3843 avatar Jun 19 '22 07:06 nasir3843

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

djrumala avatar Jan 04 '23 05:01 djrumala

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]

nasir3843 avatar Jan 05 '23 04:01 nasir3843

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.

djrumala avatar Jan 05 '23 08:01 djrumala

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 avatar Jan 05 '23 08:01 ZFTurbo

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

djrumala avatar Feb 04 '23 13:02 djrumala

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

Maidul02 avatar Aug 24 '23 00:08 Maidul02