Ich versuche, Roulette-Rad-Auswahl Tensorflow umzusetzen Also habe ich mit dieser begonnen.Tensorflow: ‚‘ Roulette-Rad“Auswahl
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
Irgendwelche Vorschläge für dieses oder ein besseres Verfahren das Roulette-Rad-Auswahl zu tun?
so ein kleines Beispiel, um es
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
klarer Dann als Ausgang ich möchte [1, 2, 1]