"TypeError: 未知参数类型:<class 'dict_values'>> [英] "TypeError: Unknown parameter type: <class 'dict_values'>"

查看:95
本文介绍了"TypeError: 未知参数类型:<class 'dict_values'>>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using this code: "https://github.com/LouisFoucard/MC_DCNN/blob/master/.ipynb_checkpoints/MultiChannel_DeepConvNet-checkpoint.ipynb"

当我运行代码时,出现以下错误:

When I run the code, I get the error that:

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

TypeError: unsupported operand type(s) for +: 'dict_values' and 'list'

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

This error is related to this line of the code:

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

我将此行更改为:

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

这次我得到的错误是:

类型错误:未知参数类型:

TypeError: Unknown parameter type:

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

This seems that Theano.function does not accept Dictionary.values as inputs?

谢谢

推荐答案

看来您正在尝试在 python 3 中运行一些 python 2 代码,其中 dict.values 返回一个 字典视图对象

It seems you are trying to run some python 2 code in python 3, where dict.values returns a dictionary view object

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

The solution is quite simple - just wrap your dict.values in a list:

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

这篇关于"TypeError: 未知参数类型:<class 'dict_values'>>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆