chainer.functions.dstack(xs)[source]

第3軸に添って(深さ毎に)変数を結合する。

 

Parameters: xs (list of Variable or numpy.ndarray or cupy.ndarray) – 結合する入力値(リスト)。この変数リストは同じ ndimでなければならない。変数リストに第3軸があるとき(つまり \(ndim \geq 3\)のとき)、この変数リストは、この第3軸以外は同じshapeでなければならない。この変数リストに第3軸がない場合s(i.e. \(ndim < 3\))、変数リストは同じshapeでなければならない。
Returns:

出力値。入力変数リストに第3軸がある場合、入力と出力のshapeは第3軸以外は同じshapeになる。第3軸の長さは入力変数リストのの第3軸の長さの合計になる。 変数のshapeが (N1, N2) (i.e. \(ndim = 2\))のとき、 出力のshape は (N1, N2, 2)

変数リストのshapeが (N1,) (i.e. \(ndim = 1\))のとき、出力の shapeは (1, N1, 2)。 変数リストのshapeが () (i.e. \(ndim = 0\))のとき、出力の shapeは (1, 1, 2)

Return type: Variable

 

Example

 


>>>
x1 = np.array((1, 2, 3))
>>> x1.shape (3,)
>>> x2 = np.array((2, 3, 4))
>>> x2.shape (3,)
>>> y = F.dstack((x1, x2))
>>> y.shape (1, 3, 2)
>>> y.data
array([[[1, 2], [2, 3], [3, 4]]])
>>> x1 = np.arange(0, 6).reshape(3, 2)

>>> x1.shape (3, 2)
>>> x1 array([[0, 1], [2, 3], [4, 5]])
>>> x2 = np.arange(6, 12).reshape(3, 2)
>>> x2.shape (3, 2)
>>> x2
array([[ 6, 7], [ 8, 9], [10, 11]])
>>> y = F.dstack([x1, x2])
>>> y.shape (3, 2, 2)
>>> y.data
array([[[ 0, 6], [ 1, 7]],
[[ 2, 8], [ 3, 9]],
[[ 4, 10], [ 5, 11]]])
>>> x1 = np.arange(0, 12).reshape(3, 2, 2)

>>> x2 = np.arange(12, 18).reshape(3, 2, 1)
>>> y = F.dstack([x1, x2])
>>> y.shape (3, 2, 3)
>>> y.data
array([[[ 0, 1, 12], [ 2, 3, 13]],
[[ 4, 5, 14], [ 6, 7, 15]],
[[ 8, 9, 16], [10, 11, 17]]])