Issue feeding a list into feed_dict in TensorFlow

后端 未结 3 1194
[愿得一人]
[愿得一人] 2020-12-04 19:54

I\'m trying to pass a list into feed_dict, however I\'m having trouble doing so. Say I have:

inputs = 10 * [tf.placeholder(tf.float32, shape=(ba         


        
3条回答
  •  情歌与酒
    2020-12-04 20:21

    feed_dict can be provided by preparing a dictionary beforehand as follows

    n = 10
    input_1 = [tf.placeholder(...) for _ in range(n)]
    input_2 = tf.placeholder(...)
    data_1 = [np.array(...) for _ in range(n)]
    data_2 = np.array(...)
    
    
    feed_dictionary = {}
    for i in range(n):
        feed_dictionary[input_1[i]] = data_1[i]
    feed_dictionary[input_2] = data_2
    sess.run(y, feed_dict=feed_dictionary)
    

提交回复
热议问题