Is there an API in NumPy (or maybe TensorFlow) to do synchronized shuffling of multiple arrays (with the same first dimension)?
For example, if I have two arrays with sizes (N, A) and (N, B), and I want to randomize the ordering of N elements of each of them, preserving the relationship between the elements of the first array and the second.
Is there an API or Python idiom to accomplish this?
Please note that combining them into a single array of N tuples, which are then shuffled with random.shuffle, may be an option that I would take as an answer, but I cannot make it work: return the original arrays (as far as I managed), since combined_array[:,0]will have a dimension (N) with objects as elements, and not a dimension (N, A), unless it is manually rebuilt with something like [x for x in combined_array[:,0]
orome source
share