title: keras - model wont work after pop()
body: <p>I have taken a standard ResNet50 model:</p>
  
  <pre><code>model = keras.applications.resnet50.ResNet50(include_top=False, 
                                       weights='imagenet',
                                       classes=10,
                                       input_shape=(224, 224, 3))
  </code></pre>
  
  <p>And added several dense layers of my own:</p>
  
  <pre><code>top_model = Sequential()
  top_model.add(Flatten(input_shape=model.output_shape[1:]))
  top_model.add(Dense(256, activation='relu'))
  top_model.add(Dropout(0.5))
  top_model.add(Dense(2, activation='softmax'))
  
  model = Model(input=model.input, output=top_model(model.output))
  </code></pre>
  
  <p>This way it works great, however, when I want to delete last Dense and Dropout layers with <code>model.pop()</code> keras wont work well:</p>
  
  <pre><code>model.layers[-1].layers
  [&lt;keras.layers.core.Flatten at 0x16b5c00b8&gt;,
   &lt;keras.layers.core.Dense at 0x16b5c0320&gt;,
   &lt;keras.layers.core.Dropout at 0x16b5c02e8&gt;,
   &lt;keras.layers.core.Dense at 0x16b5c0d68&gt;]
  
  model.layers[-1].pop()
  model.layers[-1].pop()
  model.layers[-1].layers
  
  [&lt;keras.layers.core.Flatten at 0x1ae6e5940&gt;,
   &lt;keras.layers.core.Dense at 0x1ae6e9e10&gt;]
  
  model.layers[-1].outputs = [model.layers[-1].layers[-1].output]
  model.outputs = model.layers[-1].outputs
  model.layers[-1].layers[-1].outbound_nodes = []
  </code></pre>
  
  <p>Then I just compile the model and when trying to predict, I get an error:</p>
  
  <pre><code>You must feed a value for placeholder tensor 'flatten_7_input_12' with dtype float and shape [?,1,1,2048]
  </code></pre>