title: Multi-input gradients calculation on keras with K.function
body: <h3>This model.input is a four head placeholder with size (3, 227, 227)</h3>
  
  <pre><code>input_imgs = model.input
  loss = K.max(layer_dict[layer_name].output[p[0]])
  </code></pre>
  
  <h3>compute the gradient of the input picture wrt this loss</h3>
  
  <pre><code>grads = K.gradients(loss, input_imgs)[0]
  </code></pre>
  
  <h3>this function returns the loss and grads given the input picture</h3>
  
  <pre><code>iterate = K.function(input_imgs, [grads])
  </code></pre>
  
  <p>I want to compute gradients for a siamese NN with fout head inputs, but when I apply the above K function I get a tensor of gradient with shape <code>(1, 3, 227, 227)</code>, when what I want is <code>(4, 3, 227, 227)</code>.</p>
  
  <p>What can I do to get the correct gradients?</p>