我想知道如何组合两个变量,类似于python中的append?例如,我们有两个变量(在输入数据后):
x: 尺寸为1*3y: 尺寸为1*3
现在我想要一个变量,它将x和y组合为1*3*2的大小
谢谢,
可以使用.tensor.stack来实现这一点。下面是一个工作示例:
import theano
import theano.tensor as tt
x = tt.matrix()
y = tt.matrix()
z = tt.stack([x, y], axis=2)
f = theano.function([x, y], z)
print f([[1, 2, 3]], [[4, 5, 6]])
它打印
[[[ 1. 4.]
[ 2. 5.]
[ 3. 6.]]]