Tensorflow is an open source, software library for numerical computation using data flow graphs. Nodes in the graph are called ops (short for operations), while the graph edges represent the R multi-dimensional data arrays (tensors) communicated between them. An op takes zero or more Tensors, performs some computation, and produces zero or more Tensors.
In this set of exercises, we will go through the basics of Tensorflow. By the end of this post, you will have a good understanding on variable tensor types. Before we start solving the exercises, it is recommended to check out the tutorial that this post is based on.
Before proceeding, it might be helpful to look over the help pages for the
Answers to the exercises are available here. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Create a variable
W of shape 10 x 10, filled with ones and a variable
b of shape 10 X 1, filled with zeros.
Initialize all the variables you have created before.
Initialize only the variable
Create a variable
W_dec with ten times the value of
Print the structure of the variable.
Print the values of the variable.
Save the variable
b to a directory of your choice and name the file as ‘save.ckpt’.
Restore the variable you have saved on the previous exercise.
Create a Variable named “current_state” that will be initialized to the scalar value 0. Then, create a constant named ‘five’ and with the value 5. After that, create another object named ‘new_value’ that is the addition of ‘current_state’ and ‘five’ (use
tf$add). Having done that, create a new object that you assign the ‘new_value’ to ‘current_state’.
Initialize the variable. Then, create a for loop with 5 steps where you assign the new value to the current state. Anything interesting you have noticed?