【发布时间】:2015-03-13 14:44:31
【问题描述】:
是否可以在 theano 中定义一个将矩阵(标量、向量)列表作为输入参数的函数?
这里是一个简单的例子:
import numpy as np
import theano as T
import theano.tensor as TT
a = []
a.append(np.zeros((2, 3)))
a.append(np.ones((4, 3)))
T_a = TT.matrices(len(a))
T_z = TT.concatenate(T_a)
fun = T.function(T_a,T_z)
print fun(a[0],a[1])
#but how to make this work?
print fun(a)
如果列表“a”不是两个而是数千个不同形状的元素,会发生什么? 我想到的唯一一件事就是将这些元素连接到一个大矩阵中,然后继续它。 没有更好的解决方案吗?
【问题讨论】:
标签: python list function matrix theano