torch.distributions.Categorical()

功能:根据概率分布来产生sample,产生的sample是输入tensor的index
如:
  >>> m = Categorical(torch.tensor([ 0.25, 0.25, 0.25, 0.25 ]))
  >>> m.sample()   # equal probability of 0, 1, 2, 3
  tensor(3)
 

相关文章:

  • 2022-12-23
  • 2021-09-16
  • 2021-07-08
  • 2021-04-04
  • 2021-12-26
  • 2021-08-08
  • 2022-12-23
  • 2021-06-10
猜你喜欢
  • 2021-12-12
  • 2021-11-19
  • 2021-05-08
  • 2021-11-28
  • 2021-08-29
  • 2021-10-19
  • 2021-07-19
相关资源
相似解决方案