chainer.functions.moveaxis

chainer.functions.moveaxis(x, source, destination)[source]

Move the source axes to the destination.

This function transpose the input x by moving the axes source to the axes destination. Other axes remain in their original order.

See also chainer.functions.transpose(), chainer.functions.swapaxes().

Parameters
  • x (Variable or N-dimensional array) – Input variable.

  • source (int or tuple of int) – Original positions of the axes to move. These must be unique.

  • destination (int or tuple of int) – Destination positions for each of the original axes. These must also be unique.

Returns

Variable whose axis is moved.

Return type

Variable

Example

>>> x = np.zeros((2, 3, 4, 5), np.float32)
>>> chainer.functions.moveaxis(x, 0, -1).shape
(3, 4, 5, 2)
>>> chainer.functions.moveaxis(x, (0, 3), (2, 0)).shape
(5, 3, 2, 4)