title: Delete layers of keras pretrained model
body: <p>I want to use vgg16 pre-trained model of keras. I have notice some strange behavior when trying to change the model. </p>
  
  <p>1) I have add some <code>layers</code> of the per-trained model. My problem is that tensorboard is showing the layers of the model that I didn't add into the sequence model. This is strange because I have also deleted the imported model. I think this have to do with the dependency between layers so I want to remove this dependencies.  How can I do this?</p>
  
  <p><a href="https://i.stack.imgur.com/0IMx9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0IMx9.png" alt="enter image description here"></a></p>
  
  <p>For example in this picture there is two layers that I didn't add but they are showing in the graph</p>
  
  <pre><code>vgg16_model = keras.applications.vgg16.VGG16()
  
  
  cnnModel = keras.models.Sequential()
  
  for layer in vgg16_model.layers[0:13]:
      cnnModel.add(layer)
  
  for layer in vgg16_model.layers[14:16]:
      cnnModel.add(layer)
  
  for layer in vgg16_model.layers[17:21]:
      cnnModel.add(layer)
  
  cnnModel.add(keras.layers.Dense(2048, name="compress_1"))
  cnnModel.add(keras.layers.Dense(1024, name="compress_2"))
  cnnModel.add(keras.layers.Dense(512, name="compress_3"))
  
  
  for layer in cnnModel.layers[0:4]:
      layer.trainable = False
  
  del vgg16_model
  </code></pre>
  
  <p>2) the second problem occurs when using <code>cnnModel.pop()</code>. In fact I have add all the layers but I do a pop to the layer I don't want before adding the next one this is the error I get.</p>
  
  <pre><code>Layer block4_conv2 has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `get_output_at(node_index)` instead.
  </code></pre>
  
  <p>And this is the code I am using:</p>
  
  <pre><code>for layer in vgg16_model.layers[0:14]:
      cnnModel.add(layer)
  
  cnnModel.pop()
  
  for layer in vgg16_model.layers[14:17]:
      cnnModel.add(layer)
  
  cnnModel.pop()
  
  for layer in vgg16_model.layers[17:21]:
      cnnModel.add(layer)
  </code></pre>
  
  <p><code>cnnModel.pop()</code> is working the problem only occurs when trying to add the next layer.</p>
  
  <p>Thank you for your help.</p>