1. 程式人生 > >在feed_dict中使用字串作為key

在feed_dict中使用字串作為key

tensorflow中這個樣子是可以的:(注意最後一行的feed_dict)

import tensorflow as tf
inp = tf.placeholder(tf.int32, shape=[None, None], name='input')
sess=tf.Session()
sess.run(x,feed_dict={'input:0': [1,2,3,4]})

不完善的文件裡是這麼寫的:
在這裡插入圖片描述
key可以是

  1. tf.Tensor或者tf.placeholder
  2. tf.SparseTensor
  3. a tuple

沒有說key還可以是字串,在tensor名後面加":0"就可以

相關閱讀:
Why not feed placeholders by name?
How to understand the term tensor in TensorFlow?