2024-09-27 00:22:57 发布
网友
一个样本在Pyro中的多元分布如何?我只想要一个(M, N)Beta发行版,但以下版本不起作用:
(M, N)
impor torch import pyro with pyro.plate("theta_plate", M): theta = pyro.sample("theta", pyro.distributions.Beta(concentration0=torch.ones(N), concentration1=torch.ones(N)))
使用to_event(n)来声明depent示例
to_event(n)
import torch import pyro import pyro.distributions as dist def model(N, M): with pyro.plate("theta_plate", M): theta = pyro.sample("theta", dist.Beta(torch.ones(N),1.).to_event(1)) return theta if __name__ == '__main__': print(model(10,12).shape) # (10,12)
PyTorch和Pyro发行版的语法相同:
import pyro.distributions as dist samples = dist.Beta(2, 2).sample([200]) # Will draw 200 samples.
除非你只是想对一个分布进行抽样,否则你不应该使用盘子的概念
使用
to_event(n)
来声明depent示例PyTorch和Pyro发行版的语法相同:
除非你只是想对一个分布进行抽样,否则你不应该使用盘子的概念
相关问题 更多 >
编程相关推荐