Is there an idiom or API for synchronized shuffling of Python arrays? -


is there api in numpy (or perhaps tensorflow) performing synchronized shuffling of several arrays (with same first dimension)?

for example, if 2 arrays dimensions (n, a) , (n, b), , want randomize ordering of n elements of each, while maintaining association between elements of first array , second.

is there api or python idiom accomplishing this?


note combining these single array of n tuples shuffled random.shuffle might option i'd accept answer, can't work: getting original arrays (as near i've managed) messy since combined_array[:,0] have dimension (n,) objects elements, rather dimension (n, a), unless manually rebuilt like [x x in combined_array[:,0]

permutation = numpy.random.permutation(n)  arr1_shuffled = arr1[permutation] arr2_shuffled = arr2[permutation] 

pick 1 permutation , use both arrays.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -