placeholder使用
- 代码如下:
#!/usr/bin/python
import tensorflow as tf
x1 = tf.placeholder(tf.int32,shape=[1],name='x1')
x2 = tf.constant(5,name = 'x2')
result = x1 + x2
with tf.Session() as sess:print(sess.run(result,{x1:[3]}))
x1 定义为placeholder
x2定义为constant
- 执行结果如下
tf.placeholder(
dtype,
shape=None,
name=None
)
dtype: The type of elements in the tensor to be fed.
shape: The shape of the tensor to be fed (optional). If the shape is not specified, you can feed a tensor of any shape.
name: A name for the operation (optional).
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!