0

list X[1, 100, 5], list Y[1, 100] is in python, tensorflow

I want to shuffle, X's 100 and Y's 100 to same random.

X = random.shuffle(X[0])
Y=random.shuffle(Y[0])

together = zip(X[0], Y[0])
together_shuffle = random.shuffle(together)

together_shuffle= zip(*together_shuffle)
X[0] = together_shuffle[0]
Y[0] = together_shuffle[1]

Is this right?

How can i do?

Md. Rezwanul Haque
  • 2,882
  • 7
  • 28
  • 45
JY Park
  • 1
  • 1
  • Where is tensorflow in this code? If `X` and `Y` are Tensors then you can't apply `random.shuffle` to them. – Vladimir Bystricky Jul 27 '17 at 07:59
  • sorry. X, Y is np.array not list. so i use sklearn.utils.shuffle(x, Y, random_stats =0). but, I don't know that is correct. if i use sklearn's shuffle , can i shuffle X'100 and Y'100 to same random? – JY Park Jul 27 '17 at 08:40

1 Answers1

0

In my code this returns a noneType since your manipulating list... but buy using random.sample it is working fine, as explained here : Why does random.shuffle return None?

as for selecting the first two coordinate of X i don't think it's going to work like that maybe you want to extract them by hand like AUX = X[:,:,0] if i understood what you wanted

J.Zagdoun
  • 124
  • 1
  • 16
  • sorry. X, Y is np.array not list. so i use sklearn.utils.shuffle(x, Y, random_stats =0). but, I don't know that is correct. if i use sklearn's shuffle , can i shuffle X'100 and Y'100 to same random? – JY Park Jul 27 '17 at 08:37
  • yes but (if i understood correctly ) you want to shuffle the result of the 'zipping' of X and Y And zip() returns a list as said in here : https://docs.python.org/2/library/functions.html#zip – J.Zagdoun Jul 27 '17 at 08:39
  • I don't know about sklearn's shuffle tho but if you want to shuffle the arrays without loosing the placement information above answer is correct – J.Zagdoun Jul 27 '17 at 08:42