title: Tensorflow minimise with respect to only some elements of a variable
body: <p>Is it possible to minimise a loss function by changing only some elements of a variable? In other words, if I have a variable <code>X</code> of length 2, how can I minimise my loss function by changing <code>X[0]</code> and keeping <code>X[1]</code> constant?</p>
  
  <p>Hopefully this code I have attempted will describe my problem:</p>
  
  <pre><code>import tensorflow as tf
  import tensorflow.contrib.opt as opt
  
  X = tf.Variable([1.0, 2.0])
  X0 = tf.Variable([3.0])
  
  Y = tf.constant([2.0, -3.0])
  
  scatter = tf.scatter_update(X, [0], X0)
  
  with tf.control_dependencies([scatter]):
      loss = tf.reduce_sum(tf.squared_difference(X, Y))
  
  opt = opt.ScipyOptimizerInterface(loss, [X0])
  
  init = tf.global_variables_initializer()
  
  with tf.Session() as sess:
      sess.run(init)
      opt.minimize(sess)
  
      print("X: {}".format(X.eval()))
      print("X0: {}".format(X0.eval()))
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>INFO:tensorflow:Optimization terminated with:
    Message: b'CONVERGENCE: NORM_OF_PROJECTED_GRADIENT_&lt;=_PGTOL'
    Objective function value: 26.000000
    Number of iterations: 0
    Number of functions evaluations: 1
  X: [3. 2.]
  X0: [3.]
  </code></pre>
  
  <p>where I would like to to find the optimal value of <code>X0 = 2</code> and thus <code>X = [2, 2]</code></p>
  
  <p><strong>edit</strong></p>
  
  <p>Motivation for doing this: I would like to import a trained graph/model and then tweak various elements of some of the variables depending on some new data I have.  </p>