diff options
Diffstat (limited to 'tensorflow/g3doc/how_tos/variable_scope/index.md')
-rw-r--r-- | tensorflow/g3doc/how_tos/variable_scope/index.md | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/tensorflow/g3doc/how_tos/variable_scope/index.md b/tensorflow/g3doc/how_tos/variable_scope/index.md index f96734ca5b..2b4315aaa8 100644 --- a/tensorflow/g3doc/how_tos/variable_scope/index.md +++ b/tensorflow/g3doc/how_tos/variable_scope/index.md @@ -1,4 +1,4 @@ -# Sharing Variables <a class="md-anchor" id="AUTOGENERATED-sharing-variables"></a> +# Sharing Variables You can create, initialize, save and load single variables in the way described in the [Variables HowTo](../../how_tos/variables/index.md). @@ -7,7 +7,7 @@ variables and you might want to initialize all of them in one place. This tutorial shows how this can be done using `tf.variable_scope()` and the `tf.get_variable()`. -## The Problem <a class="md-anchor" id="AUTOGENERATED-the-problem"></a> +## The Problem Imagine you create a simple model for image filters, similar to our [Convolutional Neural Networks Tutorial](../../tutorials/deep_cnn/index.md) @@ -88,7 +88,7 @@ For a lighter solution, not involving classes, TensorFlow provides a *Variable Scope* mechanism that allows to easily share named variables while constructing a graph. -## Variable Scope Example <a class="md-anchor" id="AUTOGENERATED-variable-scope-example"></a> +## Variable Scope Example Variable Scope mechanism in TensorFlow consists of 2 main functions: @@ -162,9 +162,9 @@ with tf.variable_scope("image_filters") as scope: This is a good way to share variables, lightweight and safe. -## How Does Variable Scope Work? <a class="md-anchor" id="AUTOGENERATED-how-does-variable-scope-work-"></a> +## How Does Variable Scope Work? -### Understanding `tf.get_variable()` <a class="md-anchor" id="AUTOGENERATED-understanding--tf.get_variable---"></a> +### Understanding `tf.get_variable()` To understand variable scope it is necessary to first fully understand how `tf.get_variable()` works. @@ -210,7 +210,7 @@ with tf.variable_scope("foo", reuse=True): assert v1 == v ``` -### Basics of `tf.variable_scope()` <a class="md-anchor" id="AUTOGENERATED-basics-of--tf.variable_scope---"></a> +### Basics of `tf.variable_scope()` Knowing how `tf.get_variable()` works makes it easy to understand variable scope. The primary function of variable scope is to carry a name that will @@ -268,7 +268,7 @@ with tf.variable_scope("root"): assert tf.get_variable_scope().reuse == False ``` -### Capturing variable scope <a class="md-anchor" id="AUTOGENERATED-capturing-variable-scope"></a> +### Capturing variable scope In all examples presented above, we shared parameters only because their names agreed, that is, because we opened a reusing variable scope with @@ -303,7 +303,7 @@ with tf.variable_scope("bar") assert foo_scope2.name == "foo" # Not changed. ``` -### Initializers in variable scope <a class="md-anchor" id="AUTOGENERATED-initializers-in-variable-scope"></a> +### Initializers in variable scope Using `tf.get_variable()` allows to write functions that create or reuse variables and can be transparently called from outside. But what if we wanted @@ -329,7 +329,7 @@ with tf.variable_scope("foo", initializer=tf.constant_initializer(0.4)): assert v.eval() == 0.2 # Changed default initializer. ``` -### Names of ops in `tf.variable_scope()` <a class="md-anchor" id="AUTOGENERATED-names-of-ops-in--tf.variable_scope---"></a> +### Names of ops in `tf.variable_scope()` We discussed how `tf.variable_scope` governs the names of variables. But how does it influence the names of other ops in the scope? @@ -359,7 +359,7 @@ When opening a variable scope using a captured object instead of a string, we do not alter the current name scope for ops. -## Examples of Use <a class="md-anchor" id="AUTOGENERATED-examples-of-use"></a> +## Examples of Use Here are pointers to a few files that make use of variable scope. In particular, it is heavily used for recurrent neural networks |