title: Keras Lambda layer to calculate mean
body: <p>How can i implement a Lambda layer in Keras that return the mean between two feature vectors?
  I tried this:</p>
  
  <pre><code>def mean(vects):
      x, y = vects
      return K.sum(K.mean(x+y),axis=1,keepdims=True)
  def man_dist_output_shape(shapes):
      shape1, shape2 = shapes
      return (shape1[0], 1)
  
  l = Lambda(mean, output_shape=mean_output_shape)([in1,in2])
  
  </code></pre>
  
  <p>in1 and in2 are two tensors of feature vectors of dimensions (?,2048) 
  The code above works but I don't know if putting K.mean(x+y) is correct. I also tried with </p>
  
  <pre><code>return K.sum(K.mean([x,y]),axis=1,keepdims=True)
  </code></pre>
  
  <p>But I have errors.
  And I tried <code>return K.sum((x + y)/2)</code>, that works too but it is different from the first trial.</p>