Skip to content
Advertisement

Is there a fast way to shuffle numpy image in segments?

I want to write a function that can take small images and return a permutation of them, block-wise.

Basically I want to turn this:

enter image description here

Into this:

enter image description here

There was an excellent answer in Is there a function in Python that shuffle data by data blocks? that helped me write a solution. However for ~50,000 28×28 images this takes a long time to run.

JavaScript

Advertisement

Answer

Here’s one approach based on this post

JavaScript

Sample run –

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement