2021
08-08
08-08
使用numpy实现矩阵的翻转(flip)与旋转
numpy.flip(m,axis=None)Reversetheorderofelementsinanarrayalongthegivenaxis.Theshapeofthearrayispreserved,buttheelementsarereordered.把m在axis维度进行切片,并把这个维度的index进行颠倒示例随机生成一个二维数组importnumpyasnpa=np.random.randint(1,9,size=9).reshape((3,3))[[586][317][878]]axis=0:上下翻转,意味着把行看成整体,行的顺序发生颠倒,每一行的元素不发生改变print...
继续阅读 >