首页 > 其他 > 详细

tensorflow 使用 2 Felch ,Feed

时间:2019-03-29 22:29:26      阅读:151      评论:0      收藏:0      [点我收藏+]

Felch ::在会话里可以执行多个 op ,

import tensorflow as tf


input1 = tf.constant(3.0)
input2 = tf.constant(2.0)
input3 = tf.constant(5.0)

# 加法操作
add = tf.add(input2, input3)
# 乘法操作
mul = tf.multiply(input1, add)

with tf.Session() as sess:
  # d在【】中写入 上述的两个 op ,可以同时执行
  res = sess.run([add, mul])
  print(res)
[7.0, 21.0]

 

Feed 

import tensorflow as tf

# 创建个占位符,32位的浮点型
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)

# 乘法操作
uitput = tf.multiply(input1, input2)

with tf.Session() as sess:
  # Feed 的数据以字典的形式传入
  print( sess.run(uitput, feed_dict={input1:[7.0], input2:[2.]}) )

  

[14.]

 

tensorflow 使用 2 Felch ,Feed

原文:https://www.cnblogs.com/gdwz922/p/10624566.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!