theano TypeError: Cannot convert Type TensorType(int32, matrix) (of Variable Subtensor{int64:int64:}

报错:TypeError: Cannot convert Type TensorType(int32, matrix) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(int32, vector). You can try to manually convert Subtensor{int64:int64:}.0 into a TensorType(int32, vector).

Reason: The shape of the numpy array is not directly converted to (-1,) and is directly used by theano. The 1-dimensional numpy array will be regarded as a matrix by theano, not a vector. So you need to manually convert it first.

solve:

Method 1: test_raw_y.flatten () 

Method two: test_raw_y.reshape ((-1)) 

 

 

Thanks: https://theano-users.narkive.com/59N7go8o/re-typeerror-cannot-convert-type-tensortype-int32-matrix-of-variable-subtensor-int64-int64-0-into

Published 202 original articles · 80 praised · 300,000 views +

Guess you like

Origin blog.csdn.net/qxqxqzzz/article/details/104946185