torch.poisson¶
- torch.poisson(input, generator=None) Tensor ¶
返回一个与
input
大小相同的张量,其中每个元素的采样来自于泊松分布,其速率参数由input
中对应的元素给出,即input
必须是非负的。- 参数
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.]])