“poisson_cpu“ not implemented for ‘Long‘

return torch.poisson(self.rate.expand(shape))
RuntimeError: "poisson_cpu" not implemented for 'Long'

from torch.distributions import Bernoulli,Normal,Exponential,Poisson
# Bernoulli
m = Bernoulli(torch.tensor([0.3]))#torch.tensor([0.3]) # 有 30% 可能性出现 1,70% 可能性出现 0
print("Bernoulli",m.sample())
# 正态(高斯)分布
m = Normal(torch.tensor([0.0]), torch.tensor([1.0])) #
print("Normal",m.sample())
# 指数分布
m = Exponential(torch.tensor([1.0]))
print("Exponential",m.sample())
m = Poisson(torch.tensor([4]))
print("Poisson",m.sample())
m = Poisson(torch.tensor([4.0]))
print("Poisson",m.sample())

修改tensor数值4改为float类型就可以了。

File "D:\Programs\Python\Python39\lib\site-packages\torch\distributions\distribution.py", line 53, in __init__
    raise ValueError("The parameter {} has invalid values".format(param))
ValueError: The parameter rate has invalid values

rate= torch.FloatTensor([[80.0,70,60],[50,40,30],[20,10,0]])
dist = torch.distributions.Poisson(rate=rate)
intervals = dist.sample(sample_shape=torch.Size([time + 1]))

tensor里面有0竟然出错。将0改为1就正常了。

哎呀,烦死了。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值