torch.multinomial 在功能上与 torch.distributions.categorical.Categorical 相同吗?

Functionally is torch.multinomial the same as torch.distributions.categorical.Categorical?

例如,如果我提供 [0.5, 0.5] 的概率数组,那么两个函数将以相等的概率对索引 [0,1] 进行采样?

是:

[torch.distributions.categorical.Categorical()] is equivalent to the distribution that torch.multinomial() samples from.