How do I generate a random vector in TensorFlow and maintain it for further use?
问题 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: 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