python TensorFlow PlaceHolders

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python TensorFlow PlaceHolders相关的知识,希望对你有一定的参考价值。

# create a placeholder of type float 32-bit, shape is a vector of 3 elements
a = tf.placeholder(tf.float32, shape=[3])

# create a constant of type float 32-bit, shape is a vector of 3 elements
b = tf.constant([5, 5, 5], tf.float32)

# use the placeholder as you would a constant or a variable
c = a + b # Short for tf.add(a, b)

with tf.Session() as sess:
# feed [1, 2, 3] to placeholder a via the dict {a: [1, 2, 3]}

# Remember: (tf.Session.run(fetch, feed_dict)
    print(sess.run(c, {a: [1, 2, 3]})) # the tensor a is the key, not the string ‘a’

以上是关于python TensorFlow PlaceHolders的主要内容,如果未能解决你的问题,请参考以下文章

python tensorflow 学习

python [test tensorflow] test tensorflow installation #tensorflow

python 3.8 下安装 tensorflow 1.14

Ubuntu上安装TensorFlow(python2.7版)

python3 tensorflow 安装

ImportError:没有名为“tensorflow.python”的模块与 tensorflow-gpu