【问题标题】:"TypeError: Unknown parameter type: <class 'dict_values'>"“TypeError:未知参数类型:<class 'dict_values'>”
【发布时间】:2018-12-06 18:34:47
【问题描述】:

我正在使用此代码:“https://github.com/LouisFoucard/MC_DCNN/blob/master/.ipynb_checkpoints/MultiChannel_DeepConvNet-checkpoint.ipynb

当我运行代码时,我收到以下错误:

TypeError:+ 不支持的操作数类型:“dict_values”和“list”

这个错误和这行代码有关:

train = theano.function(inps.values()+[target_values],cost, updates=updates)

我将这一行改为:

train = theano.function(inputs=[inps.values(), target_values], outputs=cost, updates=updates)

这次我得到的错误是:

TypeError:未知参数类型:

这似乎 Theano.function 不接受 Dictionary.values 作为输入?

谢谢

【问题讨论】:

标签: python dictionary input theano


【解决方案1】:

您似乎正试图在 python 3 中运行一些 python 2 代码, 其中dict.values 返回dictionary view object

解决方案非常简单 - 只需将您的 dict.values 包裹在 list 中:

train = theano.function(list(inps.values())+[target_values], cost, updates=updates)

【讨论】:

  • 感谢塞巴斯蒂安的帮助
猜你喜欢
  • 1970-01-01
  • 2017-08-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-28
  • 1970-01-01
  • 1970-01-01
  • 2020-08-01
相关资源
最近更新 更多