title: How to use lambda layer in keras?
body: <p>I want to define lambda layer to combine features with cross product, then merge those models,just like the fig. ,What should I do?</p>
  
  <p><img src="https://i.stack.imgur.com/9BKpD.jpg" alt="enter image description here"></p>
  
  <p>Test model_1, get 128 dimensions form dense, use <code>pywt</code> get two 64 dimensions feature(<code>cA,cD</code>), then return cA*cD //of course I want to combine two models ,but try model_1 first.</p>
  
  <pre><code>from keras.models import Sequential,Model
  from keras.layers import Input,Convolution2D,MaxPooling2D
  from keras.layers.core import Dense,Dropout,Activation,Flatten,Lambda
  import pywt
  
  def myFunc(x):
      (cA, cD) = pywt.dwt(x, 'db1')
  #    x=x*x
      return cA*cD
  
  batch_size=32
  nb_classes=3
  nb_epoch=20
  img_rows,img_cols=200,200
  img_channels=1
  nb_filters=32
  nb_pool=2
  nb_conv=3
  
  inputs=Input(shape=(1,img_rows,img_cols))
  x=Convolution2D(nb_filters,nb_conv,nb_conv,border_mode='valid',
                    input_shape=(1,img_rows,img_cols),activation='relu')(inputs)
  x=Convolution2D(nb_filters,nb_conv,nb_conv,activation='relu')(x)
  x=MaxPooling2D(pool_size=(nb_pool,nb_pool))(x)
  x=Dropout(0.25)(x)
  x=Flatten()(x)
  y=Dense(128,activation='relu')(x)
  cross=Lambda(myFunc,output_shape=(64,))(y)   
  predictions=Dense(nb_classes,activation='softmax')(cross)
  model = Model(input=inputs, output=predictions)
  model.compile(loss='categorical_crossentropy',optimizer='adadelta',metrics=['accuracy'])
  
  model.fit(X_train,Y_train,batch_size=batch_size,nb_epoch=nb_epoch,
            verbose=1,validation_data=(X_test,Y_test))
  </code></pre>
  
  <p>Sorry, can I ask a question about tensor?</p>
  
  <pre><code>import tensorflow as tf
  W1 = tf.Variable(np.array([[1,2],[3,4]]))
  init = tf.global_variables_initializer()
  sess = tf.Session()
  sess.run(init)
  array = W1.eval(sess)
  print (array)
  </code></pre>
  
  <p>That's right! However,</p>
  
  <pre><code>from keras import backend as K
  import numpy as np
  kvar=K.variable(np.array([[1,2],[3,4]]))
  K.eval(kvar)
  print(kvar)
  </code></pre>
  
  <p>I got <code>&lt;CudaNdarrayType(float32, matrix)&gt;</code> and <code>kvar.eval()</code> I got <code>b'CudaNdarray([[ 1.  2.]\n [ 3.  4.]])'</code>. I use keras, so how can I get array like tensorflow using keras?</p>