TensorFlow Initialise Variables in Variable Scope
In most tutorials the variables initialisation is done with
sess.run(tf.global_variables_initializer())
However if we’re running training of multiple models in a Session, global_variables_initializer()
would re-initialise all variables even if they have been trained and set. To initialise variables within a specific scope,
var_list = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES,
scope=variable_scope)
sess.run(tf.variables_initializer(var_list))