keras-vis: ImportError: cannot import name '_Conv' from 'keras.layers.convolutional'
-
Check that you are up-to-date with the master branch of keras-vis. You can update with: pip install git+git://github.com/raghakot/keras-vis.git --upgrade --no-deps
-
If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found here.
-
If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with: pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps
-
Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).
Hi,
after a fresh installation of keras-vis using
pip install -U -I git+https://github.com/raghakot/keras-vis.git
I try to import Keras by running
import keras
and encounter the following error:
ImportError: cannot import name '_Conv' from 'keras.layers.convolutional'
.
As backend for Keras I’m using Tensorflow version 2.2.0
. As far as I understood the _Conv
class is only available for older Tensorflow versions. I’ve tried to downgrade to Tensorflow 1.15.0, but then I encounter compatibility issues using Keras 2.0, as required by keras-vis.
Has anybody else encountered this issue? Is there a workaround?
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 19
_Conv method not available with later version keras 2.4, the way to solve this is use Conv2D API. You can update the saliency.py module as I did below
Sorry for late reply.
Try this: pip install keras==2.2.2 & pip install tensorflow==1.10.0
Let me know, the solution worked or not
try this: my version, got from
pip list
tensorflow 2.4.1 keras 2.4.3 keras-vis 0.5.0change following lines in
saliency.py
fromPython38\Lib\site-packages\vis\visualization\
6 from keras.layers.convolutional import Conv2D
7 from keras.layers.pooling import MaxPooling1D, MaxPooling2D, AveragePooling1D, AveragePooling2D
and33 if isinstance(layer, (Conv2D, MaxPooling1D, MaxPooling2D, AveragePooling1D, AveragePooling2D)):
still if you want to use functions like
visualize_saliency
you may probably get other errors likekeras.backend has no attribute identity
; which are really hard to solve with current versions of tensorflow and keras, at least I spent ~ 2h and in my case it doesn’t worth anymore.This lib is far behind the current changes, consider using tf_keras_vis or other visualization libs.
Try this: pip install keras==2.2.2 & pip install tensorflow==1.14.0
solved my issue… installed in Colab
It also works for me although I have to make some changes to my code. I also used Keras 2.2.2 with TensorFlow 2.0 and it was okay too. However, I moved my code to tf.keras and used the method provided in the official Keras documentation and it works like a charm:)