简体   繁体   English

Numpy原位转置

[英]Numpy In place transpose

I have a large numpy ndarray shaped (H, W, 3) 我有一个大的numpy ndarray形状(H,W,3)

I need to do this 我需要这样做

new_arr = arr[:, :, [2,1,0]]

I timed it and it takes a few ms. 我为它计时,这花了几毫秒。 And my understanding is that this is a copy. 我的理解是,这是副本。 Is there an place operation that is faster? 是否有更快的放置操作?

I recently made a library for performing in-place transpositions for 2d, 3d, and 4d arrays. 我最近制作了一个库,用于执行2d,3d和4d阵列的原位转置。 In place transposition is faster than numpy for square matrices. 对于正方形矩阵,就地转置比numpy快。 Otherwise, it is more memory efficient, but slower. 否则,它的内存效率更高,但速度较慢。

https://github.com/seung-lab/fastremap https://github.com/seung-lab/fastremap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM