python - random but consistent permutation of two numpy arrays -
currently im facing problem regarding permutation of 2 numpy arrays of different row sizes, know how to utilize np.random.shuffle function cannot seem find solution specific problem, examples numpy documentation refers nd arrays same row sizes, e.g x.shape=[10][784] y.shape=[10][784]
i want permute/random shuffle column values in consistent order both arrays shapes:x.shape=[60000][784], y.shape=[10000][784].
e.g.
x[59000] = [0,1,2,3,4,5,6,7,8,9] y[9999] = [0,1,2,3,4,5,6,7,8,9]
after permutation, both of them should shuffled in same consistent way e.g.
x[59000] = [3,0,1,6,7,2,9,8,4,5] y[9999] = [3,0,1,6,7,2,9,8,4,5]
the shuffle order needs consistent on 2 arrays have different row sizes. seem valueerror: found input variables inconsistent numbers of samples: [60000, 10000]" ideas on how fix issue? appreciate help!
stick arrays , permute combined array:
merged = numpy.concatenate([x, y]) numpy.shuffle(merged.t) x, y = numpy.split(merged, [x.shape[0]])
Comments
Post a Comment