In this notebook, we execute elementary TensorFlow computational graphs.
In [1]:
import numpy as np
import tensorflow as tf
In [2]:
x1 = tf.placeholder(tf.float32)
x2 = tf.placeholder(tf.float32)
In [3]:
sum_op = tf.add(x1, x2)
product_op = tf.multiply(x1, x2)
In [4]:
with tf.Session() as session:
sum_result = session.run(sum_op, feed_dict={x1: 2.0, x2: 0.5}) # run again with {x1: [2.0, 2.0, 2.0], x2: [0.5, 1.0, 2.0]}
product_result = session.run(product_op, feed_dict={x1: 2.0, x2: 0.5}) # ...and with {x1: [2.0, 4.0], x2: 0.5}
In [5]:
sum_result
Out[5]:
In [6]:
product_result
Out[6]:
In [7]:
with tf.Session() as session:
sum_result = session.run(sum_op, feed_dict={x1: [2.0, 2.0, 2.0], x2: [0.5, 1.0, 2.0]})
product_result = session.run(product_op, feed_dict={x1: [2.0, 4.0], x2: 0.5})
In [8]:
sum_result
Out[8]:
In [9]:
product_result
Out[9]:
In [ ]: