title: How to load MobileNet weights with an input tensor in Keras
body: <p>I'm trying to apply transfer learning to MNIST using MobileNet weights in Keras. Keras documentation to use MobileNet <a href="https://keras.io/applications/#mobilenet" rel="nofollow noreferrer">https://keras.io/applications/#mobilenet</a></p>
  
  <p>Mobilenet accepts 224x224x3 as input but MNIST is 28x28x1. I'm creating a Lambda layer which can convert 28x28x1 image into 224x224x3 and send it as input to MobileNet. The following code causes</p>
  
  <p>TypeError: Input layers to a <code>Model</code> must be <code>InputLayer</code> objects. Received inputs: Tensor("lambda_2/ResizeNearestNeighbor:0", shape=(?, 224, 224, 3), dtype=float32). Input 0 (0-based) originates from layer type <code>Lambda</code>.</p>
  
  <pre><code>height = 28
  width = 28
  input_image = Input(shape=(height,width,1))
  
  def resize_image_to_inception(x):
      x = K.repeat_elements(x, 3, axis=3)
      x = K.resize_images(x, 8, 8, data_format="channels_last")
      return x
  
  input_image_ = Lambda(resize_image_to_inception, output_shape=(224, 224, 3))(input_image)
  print(type(input_image_))
  base_model = MobileNet(input_tensor=input_image_, weights='imagenet', include_top=False)
  </code></pre>