First Graphs in TF

Load dependencies


In [1]:
import numpy as np
import tensorflow as tf

Simple arithmetic


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 [7]:
with tf.Session() as sess:
    
    sum_result = sess.run(sum_op, feed_dict={x1: 2, x2: [1, 2, 3]})
    
    product_result = sess.run(product_op, feed_dict={x1: 2, x2: [1, 2, 3]})

In [8]:
sum_result


Out[8]:
array([ 3.,  4.,  5.], dtype=float32)

In [9]:
product_result


Out[9]:
array([ 2.,  4.,  6.], dtype=float32)

In [ ]: