torch.poisson¶
- torch.poisson(input, generator=None) Tensor ¶
返回一个与
input
相同大小的张量,其中每个元素从由input
中对应元素给出的泊松分布中采样,即,input
必须是非负的。- 参数:
输入(张量)- 包含泊松分布率的输入张量
- 关键字参数:
生成器(
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.]])