예제 #1
0
 def guide():
     with pyro.plate("plate", len(data), dim=-1):
         p = pyro.param("p", ops.ones(len(data), 3) / 3, event_dim=1)
         pyro.sample("x", dist.Categorical(p))
     return p
예제 #2
0
 def model(x, y=None):
     coefs = pyro.sample('coefs', dist.Normal(ops.zeros(dim),
                                              ops.ones(dim)))
     intercept = pyro.sample('intercept', dist.Normal(0., 1.))
     logits = ops.sum(coefs * x, axis=-1) + intercept
     return pyro.sample('obs', dist.Bernoulli(logits=logits), obs=y)
예제 #3
0
 def model():
     locs = pyro.param("locs", ops.tensor([-1., 0., 1.]))
     with pyro.plate("plate", len(data), dim=-1):
         x = pyro.sample("x", dist.Categorical(ops.ones(3) / 3))
         pyro.sample("obs", dist.Normal(locs[x], 1.), obs=data)