title: Can we get weights by name in keras?
body: <p>It is possible to get the layer object of a model <code>model</code> by doing <code>model.get_layer(&quot;layer_name&quot;)</code>.</p>
  <p><strong>Is there any keras function to do something similar to the weights?</strong></p>
  <p>The usage would be something like
  <code>model.get_layer(&quot;layer_name&quot;).get_variable_by_name(&quot;recurrent_kernel&quot;)</code></p>
  <p>In a Layer built with the a recurrent weight defined as the following:</p>
  <pre><code>self.recurrent_kernel = self.add_weight(shape=(self.units, self.units),
          initializer=self.recurrent_initializer,
          name=&quot;recurrent_kernel&quot;, trainable=self.train_recurrent)
  </code></pre>
  <p>EDIT: This is not the solution I am looking for: <a href="https://stackoverflow.com/questions/56002345/why-get-tensor-by-name-cant-get-the-weights-of-layers-defined-by-tf-keras-layer">Why get_tensor_by_name can&#39;t get the weights of layers defined by tf.keras.layers properly</a></p>