ReactiveBayes / ReactiveBayes/ExponentialFamilyProjection.jl

Provide AD-based defaults for GaussNewton strategy, and default for ContinuousMultivariateLogPdf

Open
#71 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Julia
Stars
11
Forks
1
PR merge metrics
No merged PRs in 30d

Description

I think my use case may be general/common enough to bake in as the default for projecting Continuous(Uni)MultivariateLogPdf functions using the Bonnet/GaussNewton strategies.

The following is the code I use to project my ContinuousMultivariateLogPdf onto Gaussian:

# using previously defined my_pdf <: ContinuousMultivariateLogPdf
function my_logpdf!(out, x)
    out[1] = my_pdf.logpdf(x)
    return out
end
function my_grad!(out, x)
    out .= ForwardDiff.gradient(my_pdf.logpdf, x)
    return out
end
function my_hess!(out, x)
    out .= ForwardDiff.hessian(my_pdf.logpdf, x)
    return out
end

inplace = ExponentialFamilyProjection.InplaceLogpdfGradHess(my_logpdf!, my_grad!, my_hess!)
params = ProjectionParameters(
    tolerance = 1e-8,
    strategy = ExponentialFamilyProjection.GaussNewton(nsamples = 1), # deterministic
)
prj = ProjectedTo(MvNormalMeanCovariance, D; parameters = params)
result = project_to(prj, inplace) # <--- note inplace

So, it seems to me that what is feasible and good would be to allow the following to be automatically equivalent to the above by default, without providing the three mutation-functions:

# using previously defined my_pdf <: ContinuousMultivariateLogPdf
params = ProjectionParameters(
    tolerance = 1e-8,
    strategy = ExponentialFamilyProjection.GaussNewton(nsamples = 1), # deterministic
)
prj = ProjectedTo(MvNormalMeanCovariance, D; parameters = params)
result = project_to(prj, my_pdf) # <--- note my_pdf is here now, instead of inplace

And so we are saying, okay, if you provide just a pdf with this strategy, we assume you intend AD-based grad/hess.

And sure, if we want a different AD-library (e.g. DifferentiationInterface.jl), we bake that in instead

Good? :)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ProjectedTo, project_to, ProjectionParameters, and GaussNewton entry points mentioned in the example, then trace how ContinuousMultivariateLogPdf inputs are handled. Determine how the default AD-based gradient and Hessian behavior should interact with the strategy choice. Done means the PDF-only example works equivalently to the explicit InplaceLogpdfGradHess form, with the default behavior verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.