title: ValueError: Input tensors to a Model must come from `keras.layers.Input` missing metadata - trying to add lambda layer to ResNet in keras tensorflow
body: <p>I have a ResNet model that works for me. I am trying to add a couple of lambda layers to the front of it.  It is complaining with the following error:</p>
  <p>&quot;ValueError: Input tensors to a Model must come from <code>keras.layers.Input</code>. Received: Tensor(&quot;Shape:0&quot;, shape=(?,), dtype=int32) (missing previous layer metadata).&quot;</p>
  <p>and I am not sure what this means or how to fix it.</p>
  <p>I added code to the following two blocks for the lambda layers, which caused the problem. I know that I can do a numpy FFT prior to the ResNet.  Have done this previously, but am working toward having the FFT layer as the front layer of the ResNet with fixed coefficients. If there is some other way of accomplishing this, like creating another network that has the FFT lambda layer and making it sequential with the ResNet, such that error can be backpropagated through both networks, that would be ok.</p>
  <p>The main goal is to have the FFT functionality in front of the ResNet layers and be able to backpropagate the error of the ResNet classifier to before the FFT layer in the easiest/best way.</p>
  <pre><code>def resnode(x_in,filter_count,kernel_size=3,downsample=False):
      x = x_in
      x = keras_contrib.layers.InstanceNormalization()(x)
      x = keras.layers.Lambda(lambda v: tf.spectral.fft(tf.cast(v,tf.complex64)))(x) 
      x = keras.layers.Lambda(lambda v: tf.abs(tf.cast(v,tf.complex64)))(x)    
      x = keras.layers.ReLU()(x)
      x = keras.layers.Conv1D(filter_count,kernel_size,padding='same')(x)
      x = keras.layers.Dropout(0.1)(x)
      x = keras_contrib.layers.InstanceNormalization()(x)
      x = keras.layers.ReLU()(x)
      x = keras.layers.Conv1D(filter_count,kernel_size,padding='same')(x)
  
      if downsample:
          x_in = keras.layers.AveragePooling1D()(x_in)
          x = keras.layers.AveragePooling1D()(x)
  
  if x_in.shape[-1] != x.shape[-1]:
      print('convolving x_in',x_in.shape)
      x_in = keras.layers.Conv1D(filter_count,1,padding='same')(x_in)
      print('Newshape x_in',x_in.shape)
      
  x = keras.layers.Add()([x_in,x])
  
  return x
  
  def createresnet(outputs=4):  
      n_features = N    
      x_input = keras.layers.Input(shape=(None,1))
  
      x_input = tf.shape(tf.squeeze(x_input))
      x = keras.layers.Lambda(lambda v: tf.spectral.fft(tf.cast(v,tf.complex64)))(x_input) # 
      x = keras.layers.Lambda(lambda v: tf.abs(tf.cast(v,tf.complex64)))(x)
      x = tf.cast(x, tf.float32)
      x = tf.expand_dims(x, axis=0)
      x = tf.expand_dims(x, axis=2)
  
      filter_size = 32 # 
      x = resnode(x,filter_size,kernel_size=7)  # FFT layer
  
      filter_size = 32
      x = resnode(x,filter_size,kernel_size=5,downsample=True)
      filter_size = 64
      x = resnode(x,filter_size,kernel_size=5,downsample=True)
      x = resnode(x,filter_size,kernel_size=5,downsample=True)
      filter_size = 128
      x = resnode(x,filter_size,downsample=True)
      x = resnode(x,filter_size,downsample=True)
      filter_size = 128
      x = resnode(x,filter_size,downsample=True)
      x = resnode(x,filter_size,downsample=True)
      filter_size = 128
      x = resnode(x,filter_size,downsample=True)
      x = resnode(x,filter_size,downsample=True)
      filter_size = 128
      x = resnode(x,filter_size,downsample=True)
      x = resnode(x,filter_size,downsample=True)
      filter_size = 64
      x = resnode(x,filter_size,downsample=True)
  
      if False:
          filter_size = 64
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
          filter_size = 64
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
          filter_size = 128
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
          filter_size = 128
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
          filter_size = 128
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
          filter_size = 128
          x = resnode(x,filter_size)
          x = resnode(x,filter_size,downsample=True)
  
      filter_size = outputs
      x = resnode(x,filter_size,downsample=True)
      x = keras.layers.GlobalAveragePooling1D()(x)
      x = keras.layers.Activation('softmax')(x)
  
      model = keras.Model(inputs=x_input,outputs=x)
      print(model.layers[0].output)
      print(model.layers[1].output)    
  
      return model
  </code></pre>
  <p>Thanks to anyone who can help!</p>