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.]])