我想知道如何组合两个变量,类似于在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]])
Run Code Online (Sandbox Code Playgroud)
打印
[[[ 1. 4.]
[ 2. 5.]
[ 3. 6.]]]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3571 次 |
| 最近记录: |