Esempio n. 1
0
 def model1(r=True):
     model2()
     with autoname(name="inter"):
         model2()
         if r:
             model1(r=False)
     model2()
Esempio n. 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))
Esempio n. 3
0
def test_only_withs():
    def model1():
        with autoname(name="a"):
            with autoname(name="b"):
                sample("x", dist.Bernoulli(0.5))

    tr1 = poutine.trace(model1).get_trace()
    assert "a/b/x" in tr1.nodes

    tr2 = poutine.trace(autoname(model1)).get_trace()
    assert "model1/a/b/x" in tr2.nodes
Esempio n. 4
0
 def model1():
     with autoname(name="a"):
         with autoname(name="b"):
             sample("x", dist.Bernoulli(0.5))
Esempio n. 5
0
 def f2():
     with autoname(name="prefix"):
         f1()
         f1()
Esempio n. 6
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))