Choose list variable given probability of each variable

后端 未结 5 1446
野趣味
野趣味 2020-12-08 00:34

I\'ve been trying to code a program that uses the softmax activation function in the middle.

Right now, I have a list of probabilities like this:

P[0         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 01:27

    Hmm interesting, how about...

    1. Generate a number between 0 and 1.

    2. Walk the list substracting the probability of each item from your number.

    3. Pick the item that, after substraction, took your number down to 0 or below.

    That's simple, O(n) and should work :)

提交回复
热议问题