def model(N, D1, D2, data=None): with pyro.plate("plate_0", D1): alpha = pyro.sample("alpha", dist.HalfCauchy(1.)) beta = pyro.sample("beta", dist.HalfCauchy(1.)) with pyro.plate("plate_1", D2): probs = pyro.sample("probs", dist.Beta(alpha, beta)) with pyro.plate("data", N): pyro.sample("binomial", dist.Binomial(probs=probs, total_count=total_count), obs=data)
def model(J, sigma, y=None): mu = pyro.sample('mu', dist.Normal(0, 5)) tau = pyro.sample('tau', dist.HalfCauchy(5)) with pyro.plate('J', J): theta = pyro.sample('theta', dist.Normal(mu, tau)) pyro.sample('obs', dist.Normal(theta, sigma), obs=y)
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
def model(data=None): loc = pyro.param("loc", ops.tensor(2.0)) scale = pyro.param("scale", ops.tensor(1.0)) with pyro.plate("data", 1000, dim=-1): x = pyro.sample("x", dist.Normal(loc, scale), obs=data) return x
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)
def guide(): loc = pyro.param("loc", ops.tensor(0.)) scale = pyro.param("scale", ops.tensor(1.)) with pyro.plate("plate_outer", data.shape[-1], dim=-1): pyro.sample("x", dist.Normal(loc, scale))
def model(): loc = ops.tensor(3.0) with pyro.plate("plate_outer", data.shape[-1], dim=-1): x = pyro.sample("x", dist.Normal(loc, 1.)) with pyro.plate("plate_inner", data.shape[-2], dim=-2): pyro.sample("y", dist.Normal(x, 1.), obs=data)
def guide(): p = pyro.param("p", ops.tensor([0.5, 0.3, 0.2])) with pyro.plate("plate", len(data), dim=-1): pyro.sample("x", dist.Categorical(p))
def model(): locs = pyro.param("locs", ops.tensor([0.2, 0.3, 0.5])) p = ops.tensor([0.2, 0.3, 0.5]) with pyro.plate("plate", len(data), dim=-1): x = pyro.sample("x", dist.Categorical(p)) pyro.sample("obs", dist.Normal(locs[x], 1.), obs=data)