예제 #1
0
 def geometric(p):
     x = pyro.sample("x", dist.Bernoulli(p))
     if x.item() == 1.0:
         # model1()
         return x + geometric(p)
     else:
         return x
예제 #2
0
 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))
예제 #3
0
 def model():
     a = pyro.param("a", torch.tensor(0.5))
     return pyro.sample("b", dist.Bernoulli(a))
예제 #4
0
 def f2():
     f1()
     f1()
     f1()
     return pyro.sample("y", dist.Bernoulli(0.5))
예제 #5
0
 def f1():
     return pyro.sample("x", dist.Bernoulli(0.5))
예제 #6
0
 def f2():
     f1()
     for i in range(3):
         f1()
         sample("x", dist.Bernoulli(0.5))
     return sample(dist.Normal(0.0, 1.0))
예제 #7
0
 def f1():
     return sample(dist.Bernoulli(0.5))
예제 #8
0
 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))
예제 #9
0
 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))
예제 #10
0
 def f1():
     sample(dist.Normal(0, 1))
     sample(dist.Normal(0, 1))
     return sample(dist.Bernoulli(0.5))
예제 #11
0
 def model2(n):
     sample("b", dist.Bernoulli(0.5))
     if n <= 0:
         return
     else:
         model1(n)
예제 #12
0
 def model1():
     with autoname(name="a"):
         with autoname(name="b"):
             sample("x", dist.Bernoulli(0.5))
예제 #13
0
 def guide():
     sample("x", dist.Gamma(1, 1))
     return sample(dist.Bernoulli(0.5))
예제 #14
0
 def model():
     sample("x", dist.HalfNormal(1))
     return sample(dist.Bernoulli(0.5))
예제 #15
0
 def model1():
     with scope(prefix="a"):
         with scope(prefix="b"):
             pyro.sample("x", dist.Bernoulli(0.5))
예제 #16
0
 def model1(n):
     pyro.sample("a", dist.Bernoulli(0.5))
     if n <= 0:
         return
     else:
         return model2(n-1)
예제 #17
0
 def f2():
     f1()
     return sample(dist.Bernoulli(0.5))