"TypeError: 未知参数类型:<class 'dict

编程入门 行业动态 更新时间:2024-10-28 07:34:57
本文介绍了"TypeError: 未知参数类型:<class 'dict_values'>>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

I am using this code: "https://github/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 16:57:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1397123.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   类型   quot   TypeError   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!