码迷,mamicode.com
首页 > 其他好文 > 详细

TensorFlow——小练习:feed

时间:2017-07-10 11:16:23      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:print   output   session   inpu   put   类型   style   hold   run   

feed就是喂入数据

使用feed前必须要有占位符作为操作的对象,在运行操作的时候喂入数据。

 1 # _*_coding:utf-8_*_
 2 import tensorflow as tf
 3 import numpy as np
 4 
 5 input1 = tf.placeholder(tf.float32)    # 占位符要指明元素数据类型,在运行操作时,若算子有占位符,需要在运行时,通过feed_dict来指feed的数据
 6 input2 = tf.placeholder(tf.float32)
 7 
 8 output = tf.mul(input1, input2)
 9 
10 with tf.Session() as sess:
11     print(sess.run(output, feed_dict={input1:[7.0], input2:[2.]}))

 运行结果:

[ 14.]

 

TensorFlow——小练习:feed

标签:print   output   session   inpu   put   类型   style   hold   run   

原文地址:http://www.cnblogs.com/DianeSoHungry/p/7144751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!