Python 将numpy数组转换为无张量变量
我需要将给定的numpy数组转换为无张量变量。我需要这个转换后的theano obj与另一个theano变量相乘Python 将numpy数组转换为无张量变量,python,arrays,numpy,theano,Python,Arrays,Numpy,Theano,我需要将给定的numpy数组转换为无张量变量。我需要这个转换后的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 th
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的初学者,因此非常感谢您的帮助:)错误的参数导致了错误。您如何调用该函数?像
convert\u fp(np.array([1,2.],3,2)
这样的简单调用对我来说不会引起任何异常。你到底需要这个函数做什么?同样,我不能重现错误。