chainer.functions.transpose_sequence¶
-
chainer.functions.
transpose_sequence
(xs)[source]¶ Transpose a list of Variables.
This function transposes a list of
Variable
s and returns a list ofVariable
s. For example a user gives[(0, 1, 2, 3), (4, 5), (6)]
, the function returns[(0, 4, 6), (1, 5), (2), (3)]
. Note that a given list needs to be sorted by each length ofVariable
.- Parameters
xs (list of
Variable
or N-dimensional array) – Variables to transpose.- Returns
Transposed list.
- Return type
tuple of
Variable
Example
>>> lst = [chainer.Variable(np.array([1, 1, 1])), ... chainer.Variable(np.array([2, 2])), ... chainer.Variable(np.array([3]))] >>> lst [variable([1, 1, 1]), variable([2, 2]), variable([3])] >>> transposed = F.transpose_sequence(lst) >>> transposed (variable([1, 2, 3]), variable([1, 2]), variable([1]))