title: How do I generate a random vector in TensorFlow and maintain it for further use?
body: <p>I am trying to generate a random variable and use it twice. However, when I use it the second time, the generator creates a second random variable that is not identical to the first. Here is code to demonstrate:</p>
  
  <pre><code>import numpy as np
  import tensorflow as tf
  
  # A random variable
  rand_var_1 = tf.random_uniform([5],0,10, dtype = tf.int32, seed = 0)
  rand_var_2 = tf.random_uniform([5],0,10, dtype = tf.int32, seed = 0)
  
  #Op1
  z1 = tf.add(rand_var_1,rand_var_2)
  
  #Op2
  z2 = tf.add(rand_var_1,rand_var_2)
  
  init = tf.initialize_all_variables()
  
  with tf.Session() as sess:
      sess.run(init)
      z1_op = sess.run(z1)
      z2_op = sess.run(z2)
      print(z1_op,z2_op)
  </code></pre>
  
  <p>I want <code>z1_op</code> and <code>z2_op</code> to be equal. I think this is because the <code>random_uniform</code> op gets called twice. Is there a way to use TensorFlow (without using NumPy) to achieve this? </p>
  
  <p>(My use case is more complicated, but this is the distilled question.)</p>