def model(dim): y = pyro.sample('y', dist.Normal(0, 3)) pyro.sample( 'x', dist.TransformedDistribution( dist.Normal(ops.zeros(dim - 1), 1), dist.transforms.AffineTransform(0, ops.exp(y / 2))))
def model(): locs = pyro.param("locs", ops.randn(3), constraint=dist.constraints.real) scales = pyro.param("scales", ops.exp(ops.randn(3)), constraint=dist.constraints.positive) p = ops.tensor([0.5, 0.3, 0.2]) x = pyro.sample("x", dist.Categorical(p)) pyro.sample("obs", dist.Normal(locs[x], scales[x]), obs=data)
def guide(): q = pyro.param("q", ops.exp(ops.randn(3)), constraint=dist.constraints.simplex) pyro.sample("x", dist.Categorical(q))