1. placeholder
tensorflow
For the time being no element in the assignment of a call, said placeholder. The so-called placeholder to placeholder, such as when required by assignment. Command is required tf.placeholder
, the specific code:
1 import tensorflow as tf 2 a = tf.placeholder(tf.float32)
Above represents a impart to a 32-bit floating-point number. How much concrete do not know, until the time of the assignment need to know.
2 。feed_dict
feed_dict
It is used to assign the format of a typical word. For example, in the previous section on a
assignments carried out. There feed_dict={a:8}
. We assignment before and after a whole even look up:
1 >>> a = tf.placeholder(tf.float32) 2 >>> sess.run(a) 3 >>> b = tf.placeholder(tf.float32) 4 >>> multiply = tf.multiply(a,b) 5 >>> sess.run(multiply,feed_dict={a:8,b:2}) 6 16.0 7 >>> sess.close()
A first for a supplement placeholder, when we sess.run
time error, we need to tell the assignment.
We define a variable multiply
for a*b
. When run by feed_dict assignment as a dictionary, to generate a product 16