torch.poisson#
- torch.poisson(input, generator=None) Tensor#
返回一個與
input大小相同的張量,其中每個元素從具有對應input中元素的泊松分佈(Poisson distribution)進行取樣,即:input必須是非負的。- 引數
input (Tensor) – 包含泊松分佈速率引數的輸入張量
- 關鍵字引數
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.]])