Can't resolve warning while importing tensorflow in colab

Viewed 29

It keeps on showing this yellow line under every import from Tensorflow in google colaboratory. I wonder why is this happening?

from tensorflow.keras import layers
from tensorflow.keras.layers.experimental import preprocessing
from tensorflow.keras.model import Sequential

enter image description here

1 Answers

I'm experiencing this too. It's a bug in TensorFlow. If you try executing the code everything will work fine, it's just a warning. However, if you want to make the warning go away you can replace all imports that start with tensorflow.keras with keras.api._v2.keras.

In your case:

from keras.api._v2.keras import layers
from keras.api._v2.keras.layers.experimental import preprocessing
from keras.api._v2.keras import Sequential
Related