0
我尝试实现Tensorflow轮盘赌选择于是我开始用这样的:Tensorflow:“”轮盘赌”的选择
x = tf.random_uniform([tf.shape(probabilities)[0]])
cumsum = tf.cumsum(probabilities, axis=1) # cumulative sum
b = tf.greater_equal(x, cumsum) # Boolean values now
...
indices = tf.where(b) # this given indices for all the True values, I need only the first one per row
indices = indices[:,1] # we only need column index
此有任何建议或更好的方法做轮盘赌选择?
所以一个小例子,使之更加清楚
probabilities = [[0.2 0.3 0.5],
[0.1 0.6 0.3],
[0.5 0.4 0.1]]
x = [0.27, 0.86, 0.73] # drawn randomly
然后我想输出为[1,2,1]