【问题标题】:How can i feed a list into feed_dict in tensorflow? The elements of list have different shapes如何将列表输入到 tensorflow 中的 feed_dict 中? list的元素有不同的形状
【发布时间】:2019-07-04 01:17:39
【问题描述】:

我想将一个列表传递给 feed_dict,但是我在这样做时遇到了麻烦。在我的代码中:

temp1=tf.placeholder(tf.float32, [10])
temp2=tf.placeholder(tf.float32, [10,30])
temp3=tf.placeholder(tf.float32, [5,15,8])
list1.append(temp1)
list1.append(temp2)
list1.append(temp3) 

其中 list1 被输入到一个函数中。 网传:Issue feeding a list into feed_dict in TensorFlow

我写代码:

data = [np.array(...), ...] ####data is the input of list1
sess.run(y, feed_dict={i: d for i, d in zip(list1, data)})

但我得到一个错误:无效的语法

我该如何解决这个问题?

我研究了web:Issue feeding a list into feed_dict in TensorFlow它不能解决我的问题

【问题讨论】:

    标签: python list tensorflow


    【解决方案1】:

    您似乎正在尝试将 python 函数与张量对象 (list1) 一起使用。 for 循环可能不知道如何处理占位符。 也许试试:

    字典 = dict(zip(list1, data))

    【讨论】:

      猜你喜欢
      • 2016-02-14
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 2017-12-07
      • 1970-01-01
      • 2016-03-22
      • 2023-01-22
      • 2021-10-21
      相关资源
      最近更新 更多