column_stack 等同于 Theano
column_stack equivalent in Theano
我正在尝试将张量作为列堆叠到现有张量(基本上相当于 numpy 中的 column_stack)
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]])
我需要同样的张量:
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)
使用连接函数
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)
我正在尝试将张量作为列堆叠到现有张量(基本上相当于 numpy 中的 column_stack)
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]])
我需要同样的张量:
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)
使用连接函数
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)