python - 如何将列表输入到 tensorflow 中的 feed_dict 中?list的元素有不同的形状
问题描述
我想将一个列表传递给 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 被输入一个函数。根据网络:在 TensorFlow 中将列表输入到 feed_dict 的问题
我写代码:
data = [np.array(...), ...] ####data is the input of list1
sess.run(y, feed_dict={i: d for i, d in zip(list1, data)})
但我得到一个错误:无效的语法
我怎么解决这个问题?
我研究过网络:问题在 TensorFlow 中将列表输入 feed_dict它不能解决我的问题
解决方案
看起来您正在尝试将 python 函数与张量对象 (list1) 一起使用。for 循环可能不知道如何处理占位符。也许尝试:
字典 = dict(zip(list1, data))
推荐阅读
- python - 如何在重定向时修复 NoReverseMatch
- google-bigquery - 正则表达式仅捕获符号
- excel - 通过代码将数量与字体更改匹配
- r - (非常)使用逻辑回归的简单 quantstrat 交易模型
- amazon-web-services - 带有区分大小写的标头的 Redshift Unload
- json - 如何从 API 调用中解码带有动态变量的嵌套 JSON 结构
- sorting - 按自定义字段 (acf) 日期选择器和发布日期排序
- c# - 如何将列表添加到 SQL 查询?
- mysql-workbench - 我不明白“存在”在 mysql 中是如何工作的
- javascript - 设置新的元素类属性值