torch.poisson¶
- torch.poisson(input, generator=None) Tensor ¶
傳回與
input
大小相同的張量,其中每個元素都是從一個 Poisson 分佈中抽樣得到的,該分佈的速率參數由input
中對應的元素給出,即input
必須是非負數。- 參數
input (Tensor) – 包含 Poisson 分佈的速率的輸入張量
- 關鍵字參數
generator (
torch.Generator
, optional) – 用於取樣的虛擬亂數產生器 (可選)
範例
>>> 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.]])