当前位置:   article > 正文

placeholder使用_placeholder怎么用

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]}))

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

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).

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/625023
推荐阅读
相关标签
  

闽ICP备14008679号