Initial implementation of finite-difference gradient approximations for likelihood#119
Open
alexnick83 wants to merge 5 commits into
Open
Initial implementation of finite-difference gradient approximations for likelihood#119alexnick83 wants to merge 5 commits into
alexnick83 wants to merge 5 commits into
Conversation
…finite-difference hessian just diagonal).
…nstead of the sum likelihood.
538b69c to
89ae916
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements finite-difference gradient and Hessian approximations for likelihood functions as an alternative to exact analytical computations. It introduces a new method configuration option to switch between "exact" and "finite-difference" methods.
Key changes:
- Added finite-difference gradient and Hessian computation methods using 5-point stencil
- Modified likelihood API to return vectors instead of scalars from
evaluate_likelihood - Updated method calls throughout the codebase to use new API methods
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dalia/core/likelihood.py | Core implementation of finite-difference methods and new API structure |
| src/dalia/configs/likelihood_config.py | Added method configuration option |
| src/dalia/likelihoods/*.py | Updated evaluate_likelihood to return NDArray instead of float |
| src/dalia/core/model.py | Updated to use new likelihood API methods |
| src/dalia/models/coregional_model.py | Updated to use new likelihood API methods |
| src/dalia/submodels/brainiac.py | Added TODO comment about likelihood specialization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Collaborator
|
Should close #22 |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements finite-difference 5-point stencil for computing the gradient and hessian of the likelihood. Also introduces small API changes, such as the following:
Likelihoodclass now has two new methods,finite_difference_gradient_likelihoodandfinite_difference_hessian_likelihood, that implement the approximations.methodattribute that takes values in["exact", "finite-difference"]. The attribute can be used to switch between the analytical formula for gradients and the finite-difference approximation. Default value is"exact".methodattribute is used in the new methodsgradient_likelihoodandhessian_likelihoodthat callevaluate_<x>_likelihoodorfinite_difference_<x>_likelihood(x is gradient or hessian) accordingly.evaluate_likelihoodmethod now returns the full vector instead of the sum.Likelihoodclass now has anevaluate_sum_likelihoodmethod that callsevaluate_likelihoodand sums up the vector entries.