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

3.Fech_feed

时间:2019-09-28 23:50:51      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:tip   import   code   hold   ESS   port   span   imp   nbsp   

import tensorflow as tf
# Fetch:可以在session中同时计算多个tensor或执行多个操作
# 定义三个常量
input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0)
# 加法op
add = tf.add(input2,input3)
# 乘法op
mul = tf.multiply(input1, add)

with tf.Session() as sess:
    result1,result2 = sess.run([mul, add])
    print(result1,result2)
# Feed:先定义占位符,等需要的时候再传入数据
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)
# 乘法op
output = tf.multiply(input1, input2)

with tf.Session() as sess:
    print(sess.run(output, feed_dict={input1:8.0,input2:2.0}))

 

3.Fech_feed

标签:tip   import   code   hold   ESS   port   span   imp   nbsp   

原文地址:https://www.cnblogs.com/liuwenhua/p/11605306.html

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