A = np.array(range(1, 9)).reshape(2, 2, 2)
# swap 2nd and 3rd axes:
A.transpose((0, 2, 1))
I’m also trying to julia like the above python code.
trying like this…
A = reshape(1:8, 2, 2, 2)
# swap 2nd and 3rd axes:
reshape(A, [1, 3, 2])
but it is not working…
You may be looking for permutedims
.
Thank you! l will try! Good! working!
julia> A = reshape(1:8, 2, 2, 2)
2×2×2 reshape(::UnitRange{Int64}, 2, 2, 2) with eltype Int64:
[:, :, 1] =
1 3
2 4
[:, :, 2] =
5 7
6 8
julia> permutedims(A, [1, 3, 2])
2×2×2 Array{Int64,3}:
[:, :, 1] =
1 5
2 6
[:, :, 2] =
3 7
4 8