chainer.functions.permutate¶
- 
chainer.functions.permutate(x, indices, axis=0, inv=False)[source]¶
- Permutates a given variable along an axis. - This function permutate - xwith given- indices. That means- y[i] = x[indices[i]]for all- i. Note that this result is same as- y = x.take(indices).- indicesmust be a permutation of- [0, 1, ..., len(x) - 1].- When - invis- True,- indicesis treated as its inverse. That means- y[indices[i]] = x[i].- Parameters
- x ( - Variableor N-dimensional array) – Variable to permutate. A \((s_1, s_2, ..., s_N)\) -shaped float array.
- indices ( - Variableor N-dimensional array) – Indices to extract from the variable. A one-dimensional int array.
- axis (int) – Axis that the input array is permutate along. 
- inv (bool) – If - True,- indicesis treated as its inverse.
 
- Returns
- Output variable. 
- Return type
 - Example - >>> x = np.arange(6).reshape((3, 2)).astype(np.float32) >>> x array([[0., 1.], [2., 3.], [4., 5.]], dtype=float32) >>> indices = np.array([2, 0, 1], np.int32) >>> y = F.permutate(x, indices) >>> y.array array([[4., 5.], [0., 1.], [2., 3.]], dtype=float32) >>> y = F.permutate(x, indices, inv=True) >>> y.array array([[2., 3.], [4., 5.], [0., 1.]], dtype=float32) >>> indices = np.array([1, 0], np.int32) >>> y = F.permutate(x, indices, axis=1) >>> y.array array([[1., 0.], [3., 2.], [5., 4.]], dtype=float32)