title: Keras - Reuse weights from a previous layer - converting to keras tensor
body: <p>I am trying to reuse the weight matrix from a previous layer. As a toy example I want to do something like this:</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  from keras.layers import Dense, Input
  from keras.layers import merge
  from keras import backend as K
  from keras.models import Model
  
  inputs = Input(shape=(4,))
  inputs2 = Input(shape=(4,))
  dense_layer = Dense(10, input_shape=(4,))
  dense1 = dense_layer(inputs)
  
  def my_fun(my_inputs):
      w = my_inputs[0]
      x = my_inputs[1]
  
      return K.dot(w, x)
  
  merge1 = merge([dense_layer.W, inputs2], mode=my_fun)
  </code></pre>
  
  <p>The problem is that <code>dense_layer.W</code> is not a keras tensor. So I get the following error:</p>
  
  <pre><code>Exception: Output tensors to a Model must be Keras tensors. Found: dot.0
  </code></pre>
  
  <p>Any idea on how to convert <code>dense_layer.W</code> to a Keras tensor?</p>
  
  <p>Thanks</p>