Beispiel #1
0
 def model1(r=True):
     model2()
     with autoname(name="inter"):
         model2()
         if r:
             model1(r=False)
     model2()
Beispiel #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))
Beispiel #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
Beispiel #4
0
 def model1():
     with autoname(name="a"):
         with autoname(name="b"):
             sample("x", dist.Bernoulli(0.5))
Beispiel #5
0
 def f2():
     with autoname(name="prefix"):
         f1()
         f1()
Beispiel #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))