tensorflow中站位符有什么用

2025-05-15 01:33:37
推荐回答(1个)
回答1:

占位符 
占位符是定义一个可变的常量,占位符赋值后不用初始化就可以获取值。

  • import tensorflow as tf 

  • x = tf.placeholder(tf.string) 

  • y = tf.placeholder(tf.int32) 

  • z = tf.placeholder(tf.float32) 

  • with tf.Session() as sess:
       

  • output = sess.run(x, feed_dict={x: 'Test String', y: 123, z: 45.67}) 

  • print(output)

实验结果:

  • Test String