title: How to load the weights of the first few layers of Convolutional Neural Network in Keras and delete the pre-trained model?
body: <p>I have a pretrained model trained in Keras.</p>
  <p>I am trying to use that model in another task, but I don't need all the layers, but only the first 4 conv layers.</p>
  <p>I have the model saved in &quot;keras_pretrained_model.h5&quot;</p>
  <p>Is it possible to initialize the first 4 conv layers of the new model using the weights of the first 4 conv layers of the pretrained model from the '.h5' file?</p>
  <p>Is loading the whole pretrained model first always necessary??</p>
  <p>The pretrained model actually takes up a lot of space and I am not sure how to delete the pretrained model after I initializing the new model with the weights. As far as I understand, using <code>tf.keras.backend.clear_session()</code> will clear the new model created along with the old one.</p>
  <p>So, my question is</p>
  <ol>
  <li>Is there any way to initialize the weights in the new model layers without loading the whole pretrained model?</li>
  <li>If I have to load the whole pretrained model, how to delete only the pretrained model without harming the new model in any way?</li>
  </ol>