Example #1
0
 def model():
     p_latent = numpyro.sample("p_latent", FakeBeta(alpha0, beta0))
     with numpyro.plate("data", len(data)):
         numpyro.sample("obs", dist.Bernoulli(p_latent), obs=data)
     return p_latent
Example #2
0
 def guide():
     probs = numpyro.param("probs", 0.2)
     numpyro.sample("x", dist.Bernoulli(probs))
Example #3
0
 def model(data):
     w = numpyro.sample("w", dist.Bernoulli(0.6))
     x = 0
     for i, y in markov(enumerate(data)):
         x = numpyro.sample(f"x_{i}", dist.Categorical(probs[w, x]))
         numpyro.sample(f"y_{i}", dist.Normal(locs[x], 1), obs=y)
Example #4
0
 def model(data):
     alpha = jnp.array([1.1, 1.1])
     beta = jnp.array([1.1, 1.1])
     p_latent = numpyro.sample("p_latent", dist.Beta(alpha, beta))
     numpyro.sample("obs", dist.Bernoulli(p_latent), obs=data)
     return p_latent
Example #5
0
def model(data, labels):
    dim = data.shape[1]
    coefs = numpyro.sample('coefs', dist.Normal(jnp.zeros(dim), jnp.ones(dim)))
    logits = jnp.dot(data, coefs)
    return numpyro.sample('obs', dist.Bernoulli(logits=logits), obs=labels)
Example #6
0
 def model():
     numpyro.sample("c", dist.Bernoulli(0.8))
Example #7
0
 def model(data):
     x = numpyro.sample("x", dist.Bernoulli(0.5), infer={"enumerate": "parallel"})
     with numpyro.plate("N", data.shape[0], subsample_size=100, dim=-1):
         batch = numpyro.subsample(data, event_dim=0)
         numpyro.sample("obs", dist.Normal(x, 1), obs=batch)
Example #8
0
 def model(data):
     f = sample('beta', dist.Beta(1., 1.))
     sample('obs', dist.Bernoulli(f), obs=data)
Example #9
0
 def model(data):
     f = numpyro.sample("beta", dist.Beta(1.0, 1.0))
     with numpyro.plate("plate", 10):
         numpyro.deterministic("beta_sq", f**2)
         numpyro.sample("obs", dist.Bernoulli(f), obs=data)
Example #10
0
 def model(data=None):
     with numpyro.plate("dim", 2):
         beta = numpyro.sample("beta", dist.Beta(1., 1.))
     with numpyro.plate("plate", N, dim=-2):
         numpyro.deterministic("beta_sq", beta**2)
         numpyro.sample("obs", dist.Bernoulli(beta), obs=data)
Example #11
0
 def model(labels):
     coefs = numpyro.sample('coefs', dist.Normal(np.zeros(dim), np.ones(dim)))
     logits = numpyro.deterministic('logits', np.sum(coefs * data, axis=-1))
     return numpyro.sample('obs', dist.Bernoulli(logits=logits), obs=labels)
Example #12
0
 def model(data):
     f = numpyro.sample("beta", dist.Beta(1., 1.))
     with numpyro.plate("plate", 10):
         numpyro.sample("obs", dist.Bernoulli(f), obs=data)
Example #13
0
 def model(data=None):
     beta = numpyro.sample("beta", dist.Beta(np.ones(2), np.ones(2)))
     with numpyro.plate("plate", N, dim=-2):
         numpyro.sample("obs", dist.Bernoulli(beta), obs=data)
Example #14
0
 def model(data):
     f = numpyro.sample("beta", dist.Beta(1.0, 1.0))
     with numpyro.plate("N", len(data)):
         numpyro.sample("obs", dist.Bernoulli(f), obs=data)
Example #15
0
 def model():
     numpyro.sample("x", dist.Bernoulli(0.7).expand([3]))
     numpyro.sample("y", dist.Binomial(10, 0.3))
Example #16
0
 def model(data):
     f = numpyro.sample('beta', dist.Beta(jnp.ones(2), jnp.ones(2)))
     numpyro.sample('obs', dist.Bernoulli(f), obs=data)
Example #17
0
 def model():
     numpyro.sample("x", dist.Bernoulli(0.7), infer={"enumerate": "parallel"})
     y = numpyro.sample("y", dist.Binomial(10, 0.3))
     numpyro.deterministic("y2", y ** 2)
Example #18
0
 def model(data, labels):
     coefs = numpyro.sample('coefs',
                            dist.Normal(jnp.zeros(dim), jnp.ones(dim)))
     logits = jnp.sum(coefs * data, axis=-1)
     return numpyro.sample('obs', dist.Bernoulli(logits=logits), obs=labels)
Example #19
0
 def model():
     numpyro.sample("c", dist.Bernoulli(0.8))
     numpyro.sample(
         "u", dist.ImproperUniform(dist.constraints.unit_interval, (), ())
     )
Example #20
0
 def model(data, labels):
     coefs = numpyro.sample("coefs",
                            dist.Normal(jnp.zeros(dim), jnp.ones(dim)))
     offset = numpyro.sample("offset", dist.Uniform(-1, 1))
     logits = offset + jnp.sum(coefs * data, axis=-1)
     return numpyro.sample("obs", dist.Bernoulli(logits=logits), obs=labels)
Example #21
0
def discrete(prob):
    numpyro.sample("x", dist.Bernoulli(prob))
Example #22
0
 def model(data):
     f = numpyro.sample("beta", dist.Beta(1, 1))
     with numpyro.plate("plate", 20, 10, dim=-1):
         numpyro.sample("obs", dist.Bernoulli(f), obs=data)
Example #23
0
 def model(labels):
     coefs = numpyro.sample("coefs", dist.Normal(jnp.zeros(dim), jnp.ones(dim)))
     logits = numpyro.deterministic("logits", jnp.sum(coefs * data, axis=-1))
     return numpyro.sample("obs", dist.Bernoulli(logits=logits), obs=labels)
Example #24
0
 def model(data):
     f = numpyro.sample("beta",
                        dist.Beta(jnp.ones(2), jnp.ones(2)).to_event())
     with numpyro.plate("N", N):
         numpyro.sample("obs", dist.Bernoulli(f).to_event(1), obs=data)
Example #25
0
 def model():
     numpyro.sample("x", dist.Bernoulli(0.5))
Example #26
0
 def model(labels):
     coefs = sample('coefs', dist.Normal(np.zeros(dim), np.ones(dim)))
     logits = np.sum(coefs * data, axis=-1)
     return sample('obs', dist.Bernoulli(logits=logits), obs=labels)
Example #27
0
 def model(data):
     f = numpyro.sample("beta", dist.Beta(1.0, 1.0))
     numpyro.sample("obs", dist.Bernoulli(f), obs=data)
Example #28
0
 def model(data):
     alpha = np.array([1.1, 1.1])
     beta = np.array([1.1, 1.1])
     p_latent = sample('p_latent', dist.Beta(alpha, beta))
     sample('obs', dist.Bernoulli(p_latent), obs=data)
     return p_latent
Example #29
0
 def model(data):
     y_prob = numpyro.sample("y_prob", dist.Beta(1., 1.))
     with numpyro.plate("data", data.shape[0]):
         y = numpyro.sample("y", dist.Bernoulli(y_prob))
         z = numpyro.sample("z", dist.Bernoulli(0.65 * y + 0.1))
         numpyro.sample("obs", dist.Normal(2. * z, 1.), obs=data)
Example #30
0
 def model():
     c = numpyro.sample("c", dist.Gamma(1, 1))
     with handlers.collapse():
         probs = numpyro.sample("probs", dist.Beta(c, 2))
         numpyro.sample("obs", dist.Bernoulli(probs), obs=data)