a[::-1, ...][:, ::-1] np一些转置写法

import numpy as np

a = np.random.randint(0, 100, (5, 3))
b = a[::-1, ...][:, ::-1]
print(a)
print("==" * 5)
print(a[::-1, ...])
print("==" * 5)
print(b)
print("==" * 5)

c = a[::-1, ::-1, ...]
print(c)
[[91 62 71]
 [ 1 11 25]
 [ 4 19 56]
 [88 57 29]
 [48 30 65]]
==========
[[48 30 65]
 [88 57 29]
 [ 4 19 56]
 [ 1 11 25]
 [91 62 71]]
==========
[[65 30 48]
 [29 57 88]
 [56 19  4]
 [25 11  1]
 [71 62 91]]
==========
[[65 30 48]
 [29 57 88]
 [56 19  4]
 [25 11  1]
 [71 62 91]]

Process finished with exit code 0
posted @ 2023-08-08 17:35  无左无右  阅读(19)  评论(0编辑  收藏  举报