raghakot / keras-vis

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

AttributeError: module 'tensorflow.python.keras.api._v1.keras.backend' has no attribute 'identity' #214

Closed neso613 closed 2 years ago

neso613 commented 4 years ago

Hi Geek's

I am trying to visualise custom model trained on Ciphar-10 dataset. My network is like below given- `Model: "sequential"


Layer (type) Output Shape Param #

conv2d (Conv2D) (None, 30, 30, 32) 896


max_pooling2d (MaxPooling2D) (None, 15, 15, 32) 0


conv2d_1 (Conv2D) (None, 13, 13, 64) 18496


max_pooling2d_1 (MaxPooling2 (None, 6, 6, 64) 0


conv2d_2 (Conv2D) (None, 4, 4, 64) 36928


flatten (Flatten) (None, 1024) 0


dense (Dense) (None, 64) 65600


preds (Dense) (None, 10) 650

Total params: 122,570 Trainable params: 122,570 Non-trainable params: 0`

I have tried attention.ipyb script given in example/vgg folder as it is for RGB model. But I am getting this error- InvalidArgumentError: conv2d_input_1:0 is both fed and fetched.

when I run code from vis.visualization import visualize_saliency, overlay from vis.utils import utils from tensorflow.keras import activations layer_idx = utils.find_layer_idx(model, 'preds') f, ax = plt.subplots(1, 2) for i, img in enumerate([img1, img2]): grads = visualize_saliency(model, layer_idx, filter_indices=3, seed_input=img) ax[i].imshow(grads, cmap='jet')

Keras version : 2.3.1 Tensorflow version : 1.14.0

Please suggest some way. Thanks!!