Commit ae601a83 authored by Ali Yahya's avatar Ali Yahya Committed by TensorFlower Gardener
Browse files

Adds AUTO_REUSE as a reuse mode to variable scopes. This mode modifies the...

Adds AUTO_REUSE as a reuse mode to variable scopes. This mode modifies the behavior of get_variable() to create requested variables if they do not exist or return them if they do exist. It is now possible to write the following code:

  def foo():
    with tf.variable_scope("foo", reuse=tf.AUTO_REUSE):
      v = tf.get_variable("v", [1])
    return v

  v1 = foo()  # Creates v.
  v2 = foo()  # Gets the same, existing v.
  assert v1 == v2

PiperOrigin-RevId: 165642400
parent 756e7cd7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment