torch.poisson
- torch.poisson(input, generator = None) → Tensor
-
返回一个与
input
大小相同的张量,其中每个元素是从以input
中对应元素为速率参数的泊松分布中抽取的。$\text{out}_i \sim \text{Poisson}(\text{input}_i)$input
必须是一个非负数值。- 参数
-
输入 (Tensor) – 输入张量,包含泊松分布的参数
- 关键字参数
-
generator (
torch.Generator
, 可选) – 用于样本采集的伪随机数生成器
示例:
>>> rates = torch.rand(4, 4) * 5 # rate parameter between 0 and 5 >>> torch.poisson(rates) tensor([[9., 1., 3., 5.], [8., 6., 6., 0.], [0., 4., 5., 3.], [2., 1., 4., 2.]])