My notebook was working up till today. At the beginning of my colab notebook I install tf-nightly, but now it is giving me this error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-589c442233c5> in <module>()
7 import tensorflow as tf
8 from tensorflow.keras import datasets, layers, models
----> 9 from keras.preprocessing import image
10 from keras_preprocessing.image import ImageDataGenerator #check underscore or not
11 from tensorflow.keras.preprocessing import image_dataset_from_directory
2 frames
/usr/local/lib/python3.7/dist-packages/keras/backend.py in <module>()
35 from tensorflow.python.distribute import distribute_coordinator as dc
36 from tensorflow.python.distribute import distribute_coordinator_context as dc_context
---> 37 from tensorflow.python.eager.context import get_config
38 from tensorflow.python.framework import config
39 from keras import backend_config
ImportError: cannot import name 'get_config' from 'tensorflow.python.eager.context' (/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/eager/context.py)
My code:
!pip install tf-nightly
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
from keras.preprocessing import image
from keras_preprocessing.image import ImageDataGenerator
from tensorflow.keras.preprocessing import image_dataset_from_directory
from keras.callbacks import Callback, ModelCheckpoint, ReduceLROnPlateau, EarlyStopping
Installing tensorflow==2.1.0 did not work either.
Instead of:
import keras
Try:
from tensorflow import keras
These commands fixed the issue:
pip install --upgrade tensorflow
pip install --upgrade tensorflow-gpu
Try the version of Keras 2.3.1
pip install keras==2.3.1
then also install that
pip install git+https://www.github.com/keras-team/keras-contrib.git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With