笔记1
Multinomial
from torch.distributions.multinomial import Multinomial
Multinomial(total_count, probs)
- 其中total_count是采样次数,probs是一个一阶张量,其中每个分量表示取到这个数的权重
- 用.sample()方法取出器采样结果
- 如
probabilities = torch.ones([6], dtype = torch.float64) / 6
distribution = Multinomial(total_count = 1, probs = probabilities)
distribution.sample()
tensor([0., 0., 0., 0., 0., 1.], dtype=torch.float64)
probabilities = torch.tensor([0.2