python中的matlab“ permute”

matlab's “permute” in python

我正在将程序从matlab转换为Python。

matlab代码使用permute方法:

1
2
3
4
5
6
B = PERMUTE(A,ORDER) rearranges the dimensions of A so that they
%   are in the order specified by the vector ORDER.  The array produced
%   has the same values as A but the order of the subscripts needed to
%   access any particular element are rearranged as specified by ORDER.
%   For an N-D array A, numel(ORDER)>=ndims(A). All the elements of
%   ORDER must be unique.

Python / NumPy中有等效的方法吗?


这被卷入numpy.ndarray中的transpose函数。 默认行为会颠倒订单,但是您可以提供自己的订单列表。