Choose list variable given probability of each variable

后端 未结 5 1445
野趣味
野趣味 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:07

    You can easily achieve this with numpy. It has a choice function which accepts the parameter of probabilities.

    np.random.choice(
      ['pooh', 'rabbit', 'piglet', 'Christopher'], 
      5,
      p=[0.5, 0.1, 0.1, 0.3]
    )
    

提交回复
热议问题