Feeds

Until now, we have been dealing with constants and variables. We can also feed tensors during the execution of a graph. Here we have an example of feeding tensors during execution. For feeding a tensor, first we have to define the feed object using the tf.placeholder() function. After defining two feed objects, we can see how to use it inside sess.run():

    x = tf.placeholder(tf.float32) 
    y = tf.placeholder(tf.float32) 
 
    output = tf.mul(input1, input2) 
 
    with tf.Session() as sess: 
      print(sess.run([output], feed_dict={x:[8.], y:[2.]})) 
 
    # output: 
    # [array([ 16.], dtype=float32)] 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.134.229