moveaxis#
- ivy.moveaxis(a, source, destination, /, *, copy=None, out=None)[source]#
Move axes of an array to new positions..
- Parameters:
a (
Union
[Array
,NativeArray
]) – The array whose axes should be reordered.source (
Union
[int
,Sequence
[int
]]) – Original positions of the axes to move. These must be unique.destination (
Union
[int
,Sequence
[int
]]) – Destination positions for each of the original axes. These must also be unique.out (
Optional
[Union
[Array
,NativeArray
]]) – optional output array, for writing the result to. (default:None
)
- Return type:
Union
[Array
,NativeArray
]- Returns:
ret – Array with moved axes. This array is a view of the input array.
Examples
With
ivy.Array
input: >>> x = ivy.zeros((3, 4, 5)) >>> ivy.moveaxis(x, 0, -1).shape (4, 5, 3) >>> ivy.moveaxis(x, -1, 0).shape (5, 3, 4)
- Array.moveaxis(self, source, destination, /, *, copy=None, out=None)#
ivy.Array instance method variant of ivy.moveaxis. This method simply wraps the function, and so the docstring for ivy.unstack also applies to this method with minimal changes.
- Parameters:
a – The array whose axes should be reordered.
source (
Union
[int
,Sequence
[int
]]) – Original positions of the axes to move. These must be unique.destination (
Union
[int
,Sequence
[int
]]) – Destination positions for each of the original axes. These must also be unique.out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
)
- Return type:
Array
- Returns:
ret – Array with moved axes. This array is a view of the input array.
Examples
>>> x = ivy.zeros((3, 4, 5)) >>> x.moveaxis(0, -1).shape (4, 5, 3) >>> x.moveaxis(-1, 0).shape (5, 3, 4)
- Container.moveaxis(self, source, destination, /, *, copy=None, out=None)#
ivy.Container instance method variant of ivy.moveaxis. This method simply wraps the function, and so the docstring for ivy.flatten also applies to this method with minimal changes.
- Parameters:
self (
Container
) – The container with the arrays whose axes should be reordered.source (
Union
[int
,Sequence
[int
]]) – Original positions of the axes to move. These must be unique.destination (
Union
[int
,Sequence
[int
]]) – Destination positions for each of the original axes. These must also be unique.out (
Optional
[Container
]) – optional output container, for writing the result to. (default:None
)
- Return type:
Container
- Returns:
ret – Container including arrays with moved axes.
Examples
With one
ivy.Container
input: >>> x = ivy.Container(a=ivy.zeros((3, 4, 5)), b=ivy.zeros((2,7,6))) >>> x.moveaxis(, 0, -1).shape {a: (4, 5, 3) b: (7, 6, 2)
}