TensorFlow The placeholder

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/nanhuaibeian/article/details/100586599

placeholder Tensorflow placeholder is temporarily stored variables.

Tensorflow If you want the incoming data from the outside, it would need to use tf.placeholder (), then transmits the data sess.run (***, feed_dict = {input: **}) in this form.

import tensorflow as tf

# TensorFlow 中需要定义 placeholder 的 type,一般为 float32 类型
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:[7.],input2:[2.]}))

The last work of traditional values handed over sess.run(), we need to pass on the values feed_dict()={}and every one correspondence input.placeholderand feed_dict={}are bound together arise.

Guess you like

Origin blog.csdn.net/nanhuaibeian/article/details/100586599