[英]Any way to combine Theano tensor vectors similar to itertools.chain?
[英]How to combine two tensor in theano
我想知道如何組合兩個變量,類似於在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.]]]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.