tf-keras-vis
tf-keras-vis copied to clipboard
Problems with TF 2.9
Using v0.8.1 with TF 2.9rc1 leads to problems such as
ImportError: cannot import name 'Conv' from 'keras.layers.convolutional' (.../lib/python3.10/site-packages/keras/layers/convolutional/init.py)
at https://github.com/keisen/tf-keras-vis/blob/0bc00a80c04a66669df8dfd8d1137cdca9b86610/tf_keras_vis/utils/model_modifiers.py#L10
The problem seems to be that Conv
is a private API, compare https://github.com/keras-team/keras/issues/15352#issuecomment-1006830653.
It seems to be used exclusively at https://github.com/keisen/tf-keras-vis/blob/0bc00a80c04a66669df8dfd8d1137cdca9b86610/tf_keras_vis/utils/model_modifiers.py#L127
so maybe this check can be rewritten to work without Conv
.
TF 2.9 has just been released, and this issue persists:
Python 3.10.4 (main, Mar 25 2022, 13:16:33) [GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tf_keras_vis.gradcam
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../lib/python3.10/site-packages/tf_keras_vis/gradcam.py", line 10, in <module>
from .utils.model_modifiers import ExtractIntermediateLayerForGradcam as ModelModifier
File ".../lib/python3.10/site-packages/tf_keras_vis/utils/model_modifiers.py", line 10, in <module>
from keras.layers.convolutional import Conv
ImportError: cannot import name 'Conv' from 'keras.layers.convolutional' (.../lib/python3.10/site-packages/keras/layers/convolutional/__init__.py)
same issue. According to the keras source code, the workaround should be change the
from keras.layers.convolutional import Conv
to
from keras.layers.convolutional.base_conv import Conv
I don't know the exact version when the keras team refactor the conv class, so could someone find out and make a PR?