def geometric(p): x = pyro.sample("x", dist.Bernoulli(p)) if x.item() == 1.0: # model1() return x + geometric(p) else: return x
def f2(): f1() # for i in autoname(name="loop")(range(3)): <- this works too for i in autoname(range(3), name="loop"): f1() sample("x", dist.Bernoulli(0.5)) return sample(dist.Normal(0.0, 1.0))
def model(): a = pyro.param("a", torch.tensor(0.5)) return pyro.sample("b", dist.Bernoulli(a))
def f2(): f1() f1() f1() return pyro.sample("y", dist.Bernoulli(0.5))
def f1(): return pyro.sample("x", dist.Bernoulli(0.5))
def f2(): f1() for i in range(3): f1() sample("x", dist.Bernoulli(0.5)) return sample(dist.Normal(0.0, 1.0))
def f1(): return sample(dist.Bernoulli(0.5))
def f2(): for i in autoname(pyro.plate(name="data", size=3)): for j in autoname(range(2), name="xy"): f1() return sample(dist.Bernoulli(0.5))
def f2(): sample("x", dist.Bernoulli(0.5)) sample("x", dist.Bernoulli(0.5)) sample("x", dist.Bernoulli(0.5)) return sample(dist.Normal(0.0, 1.0))
def f1(): sample(dist.Normal(0, 1)) sample(dist.Normal(0, 1)) return sample(dist.Bernoulli(0.5))
def model2(n): sample("b", dist.Bernoulli(0.5)) if n <= 0: return else: model1(n)
def model1(): with autoname(name="a"): with autoname(name="b"): sample("x", dist.Bernoulli(0.5))
def guide(): sample("x", dist.Gamma(1, 1)) return sample(dist.Bernoulli(0.5))
def model(): sample("x", dist.HalfNormal(1)) return sample(dist.Bernoulli(0.5))
def model1(): with scope(prefix="a"): with scope(prefix="b"): pyro.sample("x", dist.Bernoulli(0.5))
def model1(n): pyro.sample("a", dist.Bernoulli(0.5)) if n <= 0: return else: return model2(n-1)
def f2(): f1() return sample(dist.Bernoulli(0.5))