title: Assign indexed entry of Keras tensor
body: <p>I'm something of a Keras beginner so my apologies in advance for any generally poor understanding. </p>
  
  <p>I want to manually set some values of my Keras tensor according to, say, indices stored in another tensor. I believe I understand how to access entries of a tensor using <code>tf.gather_nd</code> (my untested attempt below), and I think I understand that I can only set values of a variable and not a tensor.</p>
  
  <p>For clarity, this is taking place between the generation and discrimination stages of a GAN.</p>
  
  <pre><code>gen_out = generator(inputs)
  
  indices_to_reset = Input(shape=(1,),dtype='int32')
  new_values = Input(shape=(1,), dtype='int32')
  
  batch_size = K.shape(x)[0]
  
  idx_0 = K.reshape(K.arange(batch_size),(1,))
  indices_to_reset = K.reshape(indices_to_reset, (1,))
  
  idx = K.stack((idx_0, indices_to_reset), axis=0)
  
  grabbed_entries = Lambda(lambda x: tf.gather_nd(gen_out,x))(idx)
  
  # Doesn't work
  # gen_out[:,indices_to_reset] = new_values
  
  updated_gen_out = ???
  </code></pre>