title: How to access and visualize the weights in a pre-trained TensorFlow 2 model?
body: <p>So, I have re-trained a pre-trained ResNet50 V2 model in TensorFlow 2 using the tf.keras framework with two Dense layers added to the top. Now I want to visualize the weights in the layers <strong>within</strong> the base ResNet model. However, reloading the saved model with</p>
  
  <pre><code>model = tf.keras.models.load_model(path/to/model.hdf5)
  model.summary()
  </code></pre>
  
  <p>results in </p>
  
  <p><a href="https://i.stack.imgur.com/NmQKr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NmQKr.png" alt="enter image description here"></a></p>
  
  <p>As you can see, the layers of ResNet model are not individually listed, meaning that calling</p>
  
  <pre><code>model.layers[0].get_weights()[1]
  </code></pre>
  
  <p>will only result in </p>
  
  <pre><code>[7 7 3 64]
  </code></pre>
  
  <p>Thus, how do I access the weights inside each of the layers in the base ResNet50 V2 model? </p>