0

I am trying to run a CNN python code, but at the top of the code, the following line has keras and BatchNormalization underline in red.

from keras.layers.normalization import BatchNormalization

I don't know why there are underline. I confirmed that I have python, keras and tensorflow installed

>>> import keras
>>> keras.__version__
'2.8.0'
>>> 

>>> import tensorflow as tf
>>> print(tf. __version__)
2.8.0
>>>

(venv) PS C:\Users\PycharmProjects\Local-Binary-Patterns> python --version
Python 3.10.4
>>

Am I missing something?

Computer specs: HP Omen with Ryzen 7 CPU and GEFORCE RTX 3080 GPU. 

3 Answers 3

0

As far as I know you should import BatchNormalization like so -

from tensorflow.keras.layers import BatchNormalization
Sign up to request clarification or add additional context in comments.

3 Comments

So I did, and now BatchNormalization is underlined
you added the .normalization that I think you should get rid of
So It looks like this: from tensorflow.keras.layers import BatchNormalization
0

If the code works, don't worry about the underline.

TensorFlow uses some late-import and aliasing tricks that sometimes confuse PyCharm's code completion system.

Comments

0

I found the solution. I had to revert to old versions of Python, Keras and Tensorflow

Python: 3.9.0
Keras: 2.4.3
Tensorflow: 2.5.0

I then copied my python code and ran it with the new versions and it worked like a charm.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.