jeudi 21 janvier 2021

Randomize 2 numpy arrays the same way [duplicate]

I have 2 np.ndarray() objects and I want to randomize (or shuffle) them like this:

>>> a
[[12. 13. 24. ... 23. 45. 67.] [32. 10. 23. ... 23. 45. 67.] [12. 13. 24. ... 23. 45. 67.] ... [12. 13. 24. ... 23. 45. 67.]]
>>> b
[0. 0. 0. ... 1.]
>>> shuffle(a, b)
>>> a
[[12. 13. 24. ... 23. 45. 67.] [32. 10. 23. ... 23. 45. 67.] [12. 13. 24. ... 23. 45. 67.] ... [12. 13. 24. ... 23. 45. 67.]]
>>> b
[1. 0. 0. ... 0.]

Every number from the variable b corresponds to a label for my AI training data in the variable a.




Aucun commentaire:

Enregistrer un commentaire