0
votes

I am trying to do the following:

from keras.wrappers.scikit_learn import KerasClassifier

But I get the error:

File "", line 1, in from keras.wrappers.scikit_learn import KerasClassifier

File "/opt/anaconda3/lib/python3.7/site-packages/keras/init.py", line 3, in from . import utils

File "/opt/anaconda3/lib/python3.7/site-packages/keras/utils/init.py", line 6, in from . import conv_utils

File "/opt/anaconda3/lib/python3.7/site-packages/keras/utils/conv_utils.py", line 9, in from .. import backend as K

File "/opt/anaconda3/lib/python3.7/site-packages/keras/backend/init.py", line 15, in from .load_backend import is_variable

ImportError: cannot import name 'is_variable' from 'keras.backend.load_backend' (/opt/anaconda3/lib/python3.7/site-packages/keras/backend/load_backend.py)

I have tried uninstalling and installing keras, as well as tensorflow. But nothing changes.

I am using Tensorflow 2.1.0 and Keras 2.3.1.

Would be very happy for any help!!

1
Do you see the message "Using TensorFlow backend"?Dr. Snoopy

1 Answers

1
votes

For anyone interesting, it worked by changing: from keras.wrappers.scikit_learn import KerasClassifier

to from tf.keras.wrappers.scikit_learn import KerasClassifier