/ / column_stack equivalent w Theano - python, theano

odpowiednik column_stack w Theano - python, theano

Próbuję zestawić tensor jako kolumny z istniejącym tensorem (w zasadzie odpowiednik column_stack w numpy)

import numpy as np
a = np.asarray([[1,2,3],[4,5,6],[7,8,9]])
b = np.asarray([[11,12,13],[14,15,16],[17,18,19]])
np.column_stack((a,b))

array([[ 1,  2,  3, 11, 12, 13],
[ 4,  5,  6, 14, 15, 16],
[ 7,  8,  9, 17, 18, 19]])

Potrzebuję tego samego dla tensora:

import theano
import theano.tensor as T
import numpy as np

x = T.fmatrix()
y = T.fmatrix()
a = np.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=theano.config.floatX)
b = np.asarray([[11, 12, 13], [14, 15, 16], [17, 18, 19]], dtype=theano.config.floatX)
z = ? # do equivalent of column_stack here
t = theano.function([x, y], z)

Odpowiedzi:

1 dla odpowiedzi № 1

Użyj powiązać funkcjonować

import theano
import theano.tensor as T
import numpy as np

x = T.fmatrix()
y = T.fmatrix()
a = np.asarray([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=theano.config.floatX)
b = np.asarray([[11, 12, 13], [14, 15, 16], [17, 18, 19]], dtype=theano.config.floatX)
z = T.concatenate([x, y], axis=1)
t = theano.function([x, y], z)
print t(a, b)