title: Modify layers in resnet model
body: <p>I am trying to train resnet50 model for image classification problem. I have loaded the pretrained 'imagenet' weights before training the model on the dataset I have. I want to insert a layer (mean subtraction layer) in-between the input layer and the first convolutiuon layer. </p>
  
  
  
  <pre class="lang-python prettyprint-override"><code>model = ResNet50(weights='imagenet')
  def mean_subtract(img):
      img = T.set_subtensor(img[:,0,:,:],img[:,0,:,:] - 123.68)
      img = T.set_subtensor(img[:,1,:,:],img[:,1,:,:] - 116.779)
      img = T.set_subtensor(img[:,2,:,:],img[:,2,:,:] - 103.939)
  
      return img / 255.0
  </code></pre>
  
  <p>I want to insert <code>inputs = Lambda(mean_subtract, name='mean_subtraction')(inputs)</code> next to the input layer and connect this to the first convolution layer of resnet model without losing the weights saved.</p>
  
  <p>How do I do that?</p>
  
  <p>Thanks!</p>