Variables

Variables are going to be stateful nodes which output their current value. In this example, it's just b and W. What we mean by saying that variables are stateful is that they retain their current value over multiple executions and it's easy to restore saved values to variables:

Also, variables have other useful features; for example, they can be saved to your disk during and after training, which facilities the use that we mentioned earlier that it allows people from different companies and groups to save, store, and send over their model parameters to other people. Also, the variables are the things that you want to tune to minimize the loss and we will see how to do that soon.

It's important to know that variables in the graph, such as b and W, are still operations because, by definition, all of your nodes in the graph are operations. So, when you evaluate these operations that are holding the values of b and W during runtime, you will get the value of those variables.

We can use the Variable() function of TensorFlow to define a variable and give it some initial value:

var = tf.Variable(tf.random_normal((0,1)),name='random_values')

This line of code will define a variable of 2 by 2 and initialize it from the standard normal distribution. You can also give a name to the variable.

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

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