John Smith
John Smith

Reputation: 423

InvalidArgumentError: input_1_1:0 is both fed and fetched

I am using the visualize_activation function in keras-vis:

from vis.visualization import visualize_activation, visualize_cam
from vis.utils import utils
from keras import activations

from matplotlib import pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (18, 6)

# Utility to search for layer index by name. 
# Alternatively we can specify this as -1 since it corresponds to the last 
# layer.
layer_idx = utils.find_layer_idx(my_model, 're_lu_3')

patches = np.expand_dims(patches,axis=3)

# This is the output node we want to maximize.
filter_idx = None
img = visualize_activation(my_model, layer_idx, filter_indices=filter_idx, 
seed_input=patches[0])
plt.imshow(img[..., 0])

However, this throws the error: InvalidArgumentError: input_1_1:0 is both fed and fetched.

How to resolve this? I tried creating a copy of my_model using tf.identity, but that didn't work.

Upvotes: 3

Views: 858

Answers (1)

J3soon
J3soon

Reputation: 3153

keras-vis on pip seems broken, try installing directly on the GitHub master branch:

pip uninstall vis
pip install git+https://github.com/raghakot/keras-vis.git -U

Using the version on pip, both the MNIST and ResNet example outputs the error: InvalidArgumentError: input_1_1:0 is both fed and fetched.. After updating, they both works well.

Upvotes: 3

Related Questions