title: Creating model for gradCAM leads to "Graph disconnected"
body: <p>I have to following model, which I use to classify pictures. Via gradCAM I want to visualize the important areas in a picture. The code works flawlessly with the pretrained VGG16 model from keras. As soon as I load my own pretrained model, I get the &quot;graph disconnected&quot; error.</p>
  <pre><code>ValueError: Graph disconnected: cannot obtain value for tensor KerasTensor(type_spec=TensorSpec(shape=(None, 224, 224, 3), dtype=tf.float32, name='input_1'), name='input_1', description=&quot;created by layer 'input_1'&quot;) at layer &quot;block1_conv1&quot;. The following previous layers were accessed without issue: []
  
  
  Model: &quot;multi_class_vgg16&quot;
  _________________________________________________________________
  Layer (type)                 Output Shape              Param #   
  =================================================================
  input_2 (InputLayer)         [(None, 224, 224, 3)]     0         
  _________________________________________________________________
  tf.cast (TFOpLambda)         (None, 224, 224, 3)       0         
  _________________________________________________________________
  tf.__operators__.getitem (Sl (None, 224, 224, 3)       0         
  _________________________________________________________________
  tf.nn.bias_add (TFOpLambda)  (None, 224, 224, 3)       0         
  _________________________________________________________________
  vgg16 (Functional)           (None, 7, 7, 512)         14714688  
  _________________________________________________________________
  global_average_pooling2d (Gl (None, 512)               0         
  _________________________________________________________________
  dense (Dense)                (None, 256)               131328    
  _________________________________________________________________
  dropout (Dropout)            (None, 256)               0         
  _________________________________________________________________
  dense_1 (Dense)              (None, 64)                16448     
  _________________________________________________________________
  dropout_1 (Dropout)          (None, 64)                0         
  _________________________________________________________________
  dense_2 (Dense)              (None, 32)                2080      
  _________________________________________________________________
  dropout_2 (Dropout)          (None, 32)                0         
  _________________________________________________________________
  dense_3 (Dense)              (None, 5)                 165       
  =================================================================
  Total params: 14,864,709
  Trainable params: 150,021
  Non-trainable params: 14,714,688
  _________________________________________________________________
  </code></pre>
  <p>And this is my code to get the last conv_layers in the model.</p>
  <pre><code># find last conv layer name and get model that ends with it
  for layer in reversed(model.layers):
      # 'conv5_block3_out' with shape (None, 7, 7, 2048)
      if len(layer.output_shape) == 4:
          last_conv_layer = model.get_layer(layer.name)
          break
  # returns conv fmaps and model prediction when called
  gradModel = Model(inputs=[model.input], outputs=[last_conv_layer.output, model.output])
  </code></pre>
  <p>This is where the error appears.</p>
  <p>After that I want to calculate this gradient:</p>
  <pre><code>with tf.GradientTape() as tape:
      # get predictions from conv model and model
      (fmaps, preds) = gradModel(image)
      # get logit of winner-class
      y_c = preds[:,np.argmax(preds[:,])]
  
  grads = tape.gradient(y_c, fmaps)[0]
  grads.shape
  </code></pre>
  <p>Why does this happen?</p>