Is there an API in NumPy (or perhaps TensorFlow) for performing a synchronized shuffling of several arrays (with the same first dimension)?
For example, if I two arrays with dimensions (N, A) and (N, B), and I want to randomize the ordering of the N elements of each, while maintaining the association between the elements of the first array and the second.
Is there an API or Python idiom for accomplishing this?
Note that combining these into a single array of N tuples which are then shuffled with random.shuffle
might be an option that I'd accept as an answer, but I can't get that to work: getting the original arrays back is (as near as I've managed) messy since combined_array[:,0]
will have dimension (N,) with objects as elements, rather than dimension (N, A), unless it is manually rebuilt with something like [x for x in combined_array[:,0]