lekaha's blog Change the world     Wiki     Blog     Feed

00_multiply

Loading

In [4]:

import tensorflow as tf

Initial variables

In [9]:

a = tf.placeholder("float") # Create a symbolic variable 'a'
b = tf.placeholder("float") # Create a symbolic variable 'b'

Multiply

In [10]:

y = tf.mul(a, b) # multiply the symbolic variables

Output

In [11]:

# create a session to evaluate the symbolic expressions
with tf.Session() as sess:
    # eval expressions with parameters for a and b
    print("%f should equal 2.0" % sess.run(y, feed_dict={a: 1, b: 2}))
    print("%f should equal 9.0" % sess.run(y, feed_dict={a: 3, b: 3}))
2.000000 should equal 2.0
9.000000 should equal 9.0