fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
18.17k stars 8.53k forks source link

5.4-visualizing-what-convnets-learn input_13:0 is both fed and fetched error #97

Closed matthewchung74 closed 5 years ago

matthewchung74 commented 5 years ago

Using Keras 2.2.4, I'm working my way though this notebook 5.4-visualizing-what-convnets-learn , except I switched the model with a unet one provided by Kaggle-Carvana-Image-Masking-Challenge . The first layer of the Kaggle model looks like this, followed by the rest of the example code.

def get_unet_512(input_shape=(512, 512, 3),
                 num_classes=1):
    inputs = Input(shape=input_shape)

...

Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_13 (InputLayer)           (None, 512, 512, 3)  0    
...

from keras import models
layer_outputs = [layer.output for layer in model.layers[:8]]
activation_model = models.Model(inputs=model.input, outputs=layer_outputs)
activations = activation_model.predict(img_tensor)

Now the error I am getting is

InvalidArgumentError: input_13:0 is both fed and fetched.

Does anyone have any suggestions on how to work around this?

matthewchung74 commented 5 years ago

in case anyone else comes across this issue, i ended up doing this

layer_outputs = [layer.output for layer in model.layers[1:8]]
kashwani29 commented 4 years ago

@foobar8675 : thanks for giving solution for this....