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 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 placeholder
x_input of type ‘float32’ and shape NULL x 1, and a placeholder
y_input of type ‘float32’ and shape NULL x 1.
Feed the values 1.0 and 2.0 at
input_2 respectively and fetch them.
Create an object named
mult that multplies whatever we input to the placeholders
Feed to the
input_1 the value 2.5 and
input_2 the value 0.1. Having done that, fetch the value of
Create a placeholder named
input_3 and then an object named
add that adds whatever we input to the object
mult, and the value of placeholder
Fetch the value from ‘add’ object. For the input placeholders, feed the values 1.2, 0.1, 2.9 for
Create a placeholder of type ‘float32’ and named
X. Then create a variable named
W of shape 1X1.
Create an object named ‘alpha’ that multiplies X and W.
Create a variable named ‘b’ which initializes with zeros and has the shape 1X1. Having done that, create an object named ‘logit’ that adds ‘alpha’ with ‘b’ X and W.
Generate 100 uniformly distributed examples within (0,1) named “x_data”. Having done that, initialize the ‘W’ and ‘b’ variables. Then, fetch ‘y’ while you feed
x_data to the X placeholder.