-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Laplace approximation #59
Conversation
Would it be possible to add some inline documentation on the structs and functions? Also, possibly a stupid question but does this do a Gauss-Newton approximation to the Hessian? I wasn't sure from the code what is going on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have got to say I thought Laplace approx was easier to do 😆
More generally do you think it would make sense to rearrange the functions going from the most public ones to the most internal ones? Right now it's a bit tricky to navigate
src/laplace.jl
Outdated
lfx::LatentFiniteGP, ys; f_init=nothing, maxiter=100, newton_kwargs... | ||
) | ||
fx = lfx.fx | ||
@assert mean(fx) == zero(mean(fx)) # might work with non-zero prior mean but not checked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should avoid using @assert
and do something like mean(fx) == zero(mean(fx)) || error("Non Zero-Mean prior not supported yet")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(The reason being that @assert
can be disabled sometimes -- the docstring for @assert
is quite informative in this regard :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeaaah that's actually an argument for keeping it as an assert 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha fair enough. I have no strong opinion either way!
From what I understood from the code, the hessian is just inv(K) + Diagonal(d^2 log p(y|f) / df^2) (with some minuses missing) so the second derivatives of the log likelihood are computed exactly with ForwardDiff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly LGTM. Have answered the remaining questions posed in the other PR as well.
I kinda did it the other way around - starting with the basic building blocks and have each function's dependencies above it. Would you still want to keep separation between training & prediction? |
So what I had in mind was to have |
…vatives of _newton_inner_loop
@theogf: I reordered it; happy now?:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just have a couple of minor comments, but otherwise it looks great :D
Co-authored-by: Théo Galy-Fajou <[email protected]>
…aplace_train_intermediates explicitly
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…cesses/ApproximateGPs.jl into st/LaplaceApproximation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This should be sufficiently ready for a proper PR. It supports the AbstractGPs API, has an example notebook, and some docstrings. All of it I'm sure we can still improve on. :)