question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Constant Kernel does not work within Numpyro plate

See original GitHub issue

See title, bellow code will cause the error. If you remove the Constant kernel it seems to run fine, but errs out that the Constant is not a constant otherwise (but really it is)

with numpyro.plate('Clusters', max_clusters):
    mean = numpyro.sample("mean", dist.Normal(1.0, 5))
    expo_len = numpyro.sample("expo_len", dist.HalfNormal(5))
    k =  kernels.ExpSquared(expo_len)
    k = k + kernels.Constant(mean)#comment out this line and it runs fine 

    t = jnp.arange(1, 11)/10-1/20
    gp = GaussianProcess(k, t)
    p = sample("gp", gp.numpyro_dist())

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dfmcommented, Feb 11, 2022

This example is useful! I now see the issues, I think, and I’ll be able to give some tips. Let me play around with it a bit and report back.

0reactions
leeekcommented, Jul 22, 2022

Minor correction to get the example to work: gp.scale_tril doesn’t exist and instead should be gp.solver.scale_tril.

    def build_gp(sigma, rho, mean):
      kernel = sigma**2 * kernels.Matern52(rho)
      gp = GaussianProcess(kernel, x, diag=1e-5, mean=mean)
      return gp.loc, gp.solver.scale_tril

Thanks for the helpful example!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZeroInflatedDistribution Errors with continuous/discrete ...
If I build a model as def model(X, Y): print("Start:", X.shape, Y.shape) N = Y.shape[0] with numpyro.plate('N', N): v = sample('v', dist.
Read more >
Pyro Primitives - NumPyro documentation
Used to designate deterministic sites in the model. Note that most effect handlers will not operate on deterministic sites (except trace() ), so...
Read more >
Getting Started with NumPyro
NumPyro is a lightweight probabilistic programming library that provides a NumPy backend for Pyro. We rely on JAX for automatic differentiation and JIT ......
Read more >
Keep latent discrete parameters consistent - numpyro
I'm trying to learn how to infer discrete latent variables from observed continuous data properly in numpyro.
Read more >
NumPyro documentation - Pyro
NumPyro is a lightweight probabilistic programming library that provides a NumPy backend for Pyro. We rely on JAX.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found