Placeholders and feed dictionaries

Using tf.convert_to_tensor() to input data is convenient but it doesn't scale. Use tf.placeholder variables (dummy nodes that provide entry points for data to a computational graph). A feed_dict is a Python dictionary mapping:

input1 = tf.placeholder(tf.float32) input2 = tf.placeholder(tf.float32) output = tf.multiply(input1, input2)  with tf.Session() as sess:    print(sess.run([output], feed_dict={input1:[5.], input2:[6.]}))

The preceding code gives this output: 

[array([ 30.], dtype=float32)]

Get Neural Network Programming with TensorFlow now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.