vendredi 28 octobre 2016

Tensorflow function that returns an array of random integers different to a given int

I would like to implement a code in tensorflow, given two numbers a,b and a number "true", return an array of random integers, everyone different to the true.

In simple python using random.randint would be something like

def get_a_rand(a,b,true, S):
    for i in range(S.shape[0]):
        k = 1
        while (k == 1):
            r = (randint(a,b))
            if r!= true:                
                k = 12
                S[i] = r
            else:
                k = 1
return S

Where S for example:

S = np.zeros((4))

How can i define something like that using Tensorflow? Using this function maybe tf.random_uniform([],a ,b, dtype=tf.int32) ??




Aucun commentaire:

Enregistrer un commentaire