raghakot / keras-vis

Neural network visualization toolkit for keras
https://raghakot.github.io/keras-vis
MIT License
2.98k stars 664 forks source link

Migrate to Tensorflow 2 #217

Open rortegagit opened 4 years ago

rortegagit commented 4 years ago

Hi, I'm using keras-vis in a jupyter notebook. Google Colab has migrated to Tensorflow 2, which provokes compatibility problems when I try to run the cells that use this library (in my case, it detects as None the penultimate layer of the model when I use the visualize_cam function)

Unable to determine penultimateConvorPoolinglayer for layer_idx: -1

I think this problem may be solved by changing the imports of keras to tensorflow.keras

from tensorflow.keras.layers.convolutional import _Conv from tensorflow.keras.layers.pooling import _Pooling1D, _Pooling2D, _Pooling3D from tensorflow.keras.layers.wrappers import Wrapper from tensorflow.keras import backend as K

I'm not sure if this could harm the rest of the code, but it is the only way to maintain this library running in Google Colab.