with tf.variable_scope("foo"):
    with tf.variable_scope("bar"):
        v = tf.get_variable("v", [1])
assert v.name == "foo/bar/v:0"        

"""
Explanation: <hr style="height:3px;border:none;color:#333;background-color:#333;" />
<img style=" float:right; display:inline" src=https://upload.wikimedia.org/wikipedia/en/7/74/TensorFlow.png width="150" height="150" />
 Techniques for Deep Learning in TensorFlow 
<br/>
<br/>
<span style="color:#000; font-family: 'Bebas Neue'; font-size: 2.0em;"> TensorFlow Hands-on Tutorial </span>
<hr style="height:3px;border:none;color:#333;background-color:#333;" />

<span style="color:#000; font-family: 'Bebas Neue'; font-size: 2em;"> Outline </span>
<br/>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> Clues in TensorFlow </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> Convolutional Neural Network (CNN) on Cifar-10
 </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> First Model in TensorFlow </span> 
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.4em;">  Techniques for Deep Learning in TensorFlow  </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> Inception V3 </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> CNN for Text Classification </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> Hidden Markov Model in TensorFlow </span>
- <span style="color:#000; font-family: 'Bebas Neue'; font-size: 1.2em;"> Image Captioning in TensorFlow </span>
<br/>
<br/>
<span style="color:#000; font-family: 'Bebas Neue'; font-size: 2em;"> Complex Models </span>
<br/>
Complicated TensorFlow models can have hundreds of variables
 tf.variable_scope():  provides simple name-spacing to avoid clashes.
 tf.get_variable():  creates/accesses variables from within a variable scope.
Variable scope is a simple type of namespacing that adds prefixes to variable names within scope
End of explanation
"""


with tf.variable_scope("foo"):
    v = tf.get_variable("v", [1])
    tf.get_variable_scope().reuse_variables()
    v1 = tf.get_variable("v", [1])
assert v1 == v

"""
Explanation: Variable scopes control variable (re)use
End of explanation
"""


with tf.variable_scope("foo"):
    v = tf.get_variable("v", [1])
assert v.name == "foo/v:0"

"""
Explanation: You’ll need to use reuse_variables() to implement  Deep Networks 
Understanding get_variable
Behavior depends on whether variable reuse enabled
 Case 1: reuse set to false 
- Create and return new variable
End of explanation
"""


with tf.variable_scope("foo"):
    v = tf.get_variable("v", [1])
with tf.variable_scope("foo", reuse=True):
    v1 = tf.get_variable("v", [1])
assert v1 == v    

"""
Explanation: Case 2: Variable reuse set to true 
- Search for existing variable with given name. Raise ValueError if none found
End of explanation
"""


saver = tf.train.Saver()
save_path = saver.save(sess, model_path)
print "Model saved in file: %s" % save_path

load_path = saver.restore(sess, model_path)
print "Model restored from file: %s" % save_path

"""
Explanation: <br/>
<br/>
<span style="color:#000; font-family: 'Bebas Neue'; font-size: 2em;"> Save and Restore a model using TensorFlow </span>
<br/>
In Deep Leaning it is crucial to save your trained model including parameters, weight, and Graph.
'Saver' op to save and restore all the variables
End of explanation
"""


