将 numpy 数组转换为 theano 变量张量

Convert numpy array into theano tensor variable

我需要将给定的 numpy 数组转换为 theano 张量变量。我需要这个转换后的 theano obj 与另一个 theano 变量相乘。

def convert_fp(in_X,UpperLimit, LowerLimit):  // in_X is a numpy_array
       power = T.cast(2.**(UpperLimit - LowerLimit), theano.config.floatX)
       X = theano.shared(in_X)  // I want to the CONVERSION here
       value_tmp = X*power      // and use the converted var here

我正在使用 theano 0.9.0。我尝试了上面的代码(在查看 之后)但它导致了以下错误:

"Variable type field must be a TensorType.", x, x.type)
theano.tensor.var.AsTensorError: ('Variable type field must be a TensorType.

我是 theano 的初学者,因此我们将不胜感激 :)

错误的参数导致了错误。