Variable scope

Variable scope is a feature of TensorFlow that helps us to do the following:

  • Make sure that we have some naming conventions to retrieve them later, for example, by making them start with the word generator or discriminator, which will help us during the training of the network. We could have used the name scope feature, but this feature won't help us for the second purpose.
  • To be able to reuse or retrain the same network but with different inputs. For example, we are going to sample fake images from the generator to see how good the generator is for replicating the original ones. Also, the discriminator will have access to the real and fake images, which will make it easy for us to reuse the variables instead of creating new ones while building the computational graph.

The following statement will show how to use the variable scope feature of TensorFlow:

with tf.variable_scope('scopeName', reuse=False):
# Write your code here

You can read more about the benefits of using the variable scope feature at https://www.tensorflow.org/programmers_guide/variable_scope#the_problem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset