I\'m looking for something similar to numpy.random.choice(range(3),replacement=False,size=2,p=[0.1,0.2,0.7]) in TensorFlow.
numpy.random.choice(range(3),replacement=False,size=2,p=[0.1,0.2,0.7])
The closest Op
Op
Yes, there is. See here and here for some background information. The solution is:
z = -tf.log(-tf.log(tf.random_uniform(tf.shape(p),0,1))) _, indices = tf.nn.top_k(tf.log(p) + z, size)