title: how to take out the intermediate layer of a a pretrained keras model
body: <p>I want to use <code>VGG</code> model (tensorflow or keras pretrained model) as a feature extractor; I load the <code>VGG16 model</code>:</p>
  
  <pre><code>IMG_SHAPE = (224, 224, 3)
  vgg16 = tf.keras.applications.VGG16(input_shape = IMG_SHAPE,
                                      include_top=False,
                                      weights='imagenet')
  </code></pre>
  
  <p>Now if I have a batch of image </p>
  
  <pre><code>image_batch  =np.ones((5,224,224,3),np.float32)
  </code></pre>
  
  <p>I can get the last layer of VGG16 by</p>
  
  <pre><code>last_layer = vgg16(image_batch)
  </code></pre>
  
  <p>Does any one know to get the middle layers features given input images image_batch? That is I want to extract lower level features of the given images. Thank you very much!</p>