Skip to content

Instantly share code, notes, and snippets.

@bwengals
Last active March 21, 2024 18:05
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save bwengals/90e79d64fe9e2d496a048f0b2c6d33da to your computer and use it in GitHub Desktop.
Save bwengals/90e79d64fe9e2d496a048f0b2c6d33da to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thipokKub
Copy link

thipokKub commented May 8, 2023

This is wonderful! But On the line

delta = gp_f.prior(f"delta_{i}", X=X, dims="t")

do you mean

delta = gp_f.prior(f"delta_{i}", X=X, dims="t")

?

@bwengals
Copy link
Author

bwengals commented May 8, 2023

Ah thanks, good catch! Fixed

@theorashid
Copy link

This is cool. Is there a way to avoid a loop for gp_replicates? By passing an array of (n_gps, cov_dim, cov_dim)? As a "batch gp"? https://forum.pyro.ai/t/gaussian-processes-fit-using-plates/1742

@bwengals
Copy link
Author

yes.. but unfortunately not with batching like that. there is a way since jax's sparse matrix multiply is in pytensor now. I'll add that implementation

@kforeman
Copy link

In case anyone else is exploring using this as part of a linear model, I've forked it to show a version using prior_linearized instead: https://gist.github.com/kforeman/692542430469d016f84a17f230d8500b

@kforeman
Copy link

From there @theorashid might be able to change the size of beta_f to (n_gps, gp_f._m_star) to use the same basis function but independent coefficients for each of the child GPs. I haven't yet worked out how to get the delta deterministic working yet, though - I imagine it may have to first construct a sparse matrix (kronecker of a 3x3 identity matrix with phi_f or something like that based on @bwengals comment)?

@bwengals
Copy link
Author

bwengals commented Jun 8, 2023

Yup that's right @kforeman. I have it implemented but it's slower, I think I'm doing something wrong but haven't looked into it more yet.

@kforeman
Copy link

kforeman commented Jun 8, 2023

Interesting, I am currently using that approach but didn't actually benchmark - will find some time to see if it's actually faster or I've just slowed myself down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment