Python theano中的函数数组

Python theano中的函数数组,python,theano,Python,Theano,想要在theano中创建一个映射函数“key to function”(从预定义的有限集合中提供一个给定数字的函数);这个最小的崩溃示例不起作用 x = T.lscalar() indices_array = theano.shared(numpy.asarray(range(2))) default_function = theano.function([x], x) values_array = theano.shared(numpy.asarray([theano.function([x]

想要在theano中创建一个映射函数“key to function”(从预定义的有限集合中提供一个给定数字的函数);这个最小的崩溃示例不起作用

x = T.lscalar()
indices_array = theano.shared(numpy.asarray(range(2)))
default_function = theano.function([x], x)
values_array = theano.shared(numpy.asarray([theano.function([x], 2 * x), theano.function([x], x * x)])) # BANG!
mapping = T.switch(T.eq(indices_array, -1), default_function, values_array[indices_array])
这里是stacktrace:

Traceback (most recent call last):
  File ".../theano_sandbox.py", line xxx, in <module>
    a = T.switch(T.eq(indices_array, -1), default_function, values_array[indices_array])
  File "/usr/local/lib/python2.7/dist-packages/theano/compile/sharedvalue.py", line 144, in __getitem__
    "This shared variable contains %s" % msg)
TypeError: The generic 'SharedVariable' object is not subscriptable. This shared variable contains a Numpy array with dtype: 'object'. This data type is not currently recognized by Theano tensors: please cast your data into a supported numeric type if you need Theano tensor functionalities.
回溯(最近一次呼叫最后一次):
文件“../theano_sandbox.py”,第xxx行,在
a=T.switch(T.eq(索引数组,-1),默认函数,值数组[索引数组])
文件“/usr/local/lib/python2.7/dist packages/theano/compile/sharedvalue.py”,第144行,在__
此共享变量包含%s“%msg”
TypeError:泛型“SharedVariable”对象不可下标。此共享变量包含一个数据类型为“object”的Numpy数组。此数据类型当前未被无张量识别:如果需要无张量功能,请将数据转换为支持的数字类型。
在theano有可能吗