I have been using the introductory example of matrix multiplication in TensorFlow.
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
produ
You should think of TensorFlow Core programs as consisting of two discrete sections:
So for the code below you just Build the computational graph.
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
product = tf.matmul(matrix1, matrix2)
You need also To initialize all the variables in a TensorFlow program , you must explicitly call a special operation as follows:
init = tf.global_variables_initializer()
Now you build the graph and initialized all variables ,next step is to evaluate the nodes, you must run the computational graph within a session. A session encapsulates the control and state of the TensorFlow runtime.
The following code creates a Session object and then invokes its run method to run enough of the computational graph to evaluate product
:
sess = tf.Session()
// run variables initializer
sess.run(init)
print(sess.run([product]))