title: Keras lambda function dot product mistmatch
body: <p>I have the following function:</p>
  
  <pre><code>def transpose_dot(vects):
      x, y = vects
      # &lt;x,x&gt; + &lt;y,y&gt; - 2&lt;x,y&gt;
  
      return K.dot(x, K.transpose(y))
  </code></pre>
  
  <p>When try to evaluate it with <code>keras</code> it works </p>
  
  <pre><code>x = K.variable(np.array(np_x))
  y = K.variable(np.array(np_x))
  obj = transpose_dot
  objective_output = obj((x, y))
  print('-----------------')
  print (K.eval(objective_output))
  </code></pre>
  
  <p>result with:</p>
  
  <pre><code>[[ 1.  1.  1.  2.]
   [ 1.  2.  2.  4.]
   [ 1.  2.  2.  4.]
   [ 2.  4.  4.  8.]
  </code></pre>
  
  <p><strong>But</strong>, when try to use it as function for <code>Lambda</code> layer it does not work. </p>
  
  <pre><code>np_x = [[1, 0], [1, 1], [1, 1], [2, 2]]
  features = np.array([np_x])
  test_input = Input(shape=np.array(np_x).shape)
  dot_layer= Lambda(transpose_dot, output_shape=(4,4))([test_input, test_input])
  x = Model(inputs=test_input, outputs=dot_layer)
  x.predict(features, batch_size=1)
  </code></pre>
  
  <p>Result with </p>
  
  <pre><code>self.fn() if output_subset is None else\
  ValueError: Shape mismatch: x has 2 cols (and 4 rows) but y has 4 rows (and 2 cols)
  Apply node that caused the error: Dot22(Reshape{2}.0, Reshape{2}.0)
  Toposort index: 11
  Inputs types: [TensorType(float32, matrix), TensorType(float32, matrix)]
  Inputs shapes: [(4, 2), (4, 2)]
  Inputs strides: [(8, 4), (8, 4)]
  Inputs values: ['not shown', 'not shown']
  Outputs clients: [[Reshape{4}(Dot22.0, MakeVector{dtype='int64'}.0)]]
  </code></pre>
  
  <p>Any idea what I'm missing here?</p>
  
  <p>Edit:
  Added output of the error message</p>