我想知道如何组合两个变量,类似于在
python中追加?例如,我们有两个变量(在用数据提供之后):
x:尺寸为1 * 3
y:尺寸为1 * 3
现在我想要一个变量,它将x和y组合成1 * 3 * 2的大小
谢谢,
最佳答案 可以使用
theano.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.]]]