mercredi 25 janvier 2017

unable to copy random generated values in to variable using tensorflow

I have data in one array say size [1x9] , I am generating random number 1 to 9 and shuffling it, I want to arrange data in that order.

# generating an array of number
BCI = tf.concat(0, [tf.fill([1,3],1),tf.fill([1,3],2),tf.fill([1,3],3)])
# making it in to 1x9 
BCI1 = tf.reshape(BCI,[-1])
# generating random numbers with length of BCI and shuffling it
rn = tf.random_shuffle(tf.range(tf.shape(BCI1[0]))
rna = tf.cast(rn,tf.int32)
# rearranging data 
BCI2 = tf.gather(BCI1,rna)

print(sess.run(BCI1))
print(sess.run(rn))
print(sess.run(BCI2))
# output is 
[1 1 1 2 2 2 3 3 3]
[3 5 0 2 6 1 4 8 7]
[2 2 1 3 1 2 1 3 3] # expected to be [2 2 1 1 3 1 2 3 3]

It because I am not able to copy rn value as constant , when I am running sess.run every time it is changing. But I need the random values generated in 'rn' for testing on another ones without changing. How many times i print rn it should show the same values How to do it ?




Aucun commentaire:

Enregistrer un commentaire