“ TypeError:未知参数类型:<class'dict_values'=”“>”

时间:2018-12-06 18:34:47

标签: python dictionary input theano

我正在使用以下代码:“ 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作为输入?

谢谢

1 个答案:

答案 0 :(得分:0)

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

解决方案非常简单-只需将dict.values包装在list中即可:

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