Search code examples
pythondictionaryinputtheano

"TypeError: Unknown parameter type: <class 'dict_values'>"


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: 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)

I changed this line to:

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

This time I get the error that:

TypeError: Unknown parameter type:

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

Thanks


Solution

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

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

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