ReactiveBayes / ReactiveBayes/ReactiveMP.jl

[Enhancement]: Generalize approximate_kernel_expectation to non-square matrices

Open
#563 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Julia
Stars
118
Forks
19
Avg merge
7d 47m
Merged PRs (30d)
1

Description

Feature/Enhancement Description

Considering the current implementation (below), we note that gbar is assumed to be square of dims equal to distribution, but this is not always the case.

function approximate_kernel_expectation(method::AbstractApproximationMethod, g::Function, m::AbstractVector{T}, P::AbstractMatrix{T}) where {T <: Real}
    ndims = length(m)

    weights = getweights(method, m, P)
    points  = getpoints(method, m, P)

    gbar = zeros(ndims, ndims)
    foreach(zip(weights, points)) do (weight, point)
        axpy!(weight, g(point), gbar) # gbar = gbar + weight * g(point)
    end

    return gbar
end
Motivation / Use Case

RxGP.jl forms kernel function expectations that are non-square.

Proposed Solution

Per @HoangMHNguyen's work, the below seems to work well.

function approximate_kernel_expectation(method::AbstractApproximationMethod, g::Function, m::AbstractVector{T}, P::AbstractMatrix{T}) where {T <: Real}
    weights = getweights(method, m, P)
    points  = getpoints(method, m, P)

    gbar = g(m) .* 0.0
    foreach(zip(weights, points)) do (weight, point)
        axpy!(weight, g(point), gbar) # gbar = gbar + weight * g(point)
    end
    return gbar
end
Alternatives Considered

No response

Example Use Cases

No response

Priority (from your perspective)

Critical for my use case

Related Issues / Discussions

No response

Additional Context

No response

Contributor guide

Open the contributing guide

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 at approximate_kernel_expectation and inspect how getweights, getpoints, and g(point) are used. Check the current tests or call sites for square-matrix assumptions, then verify that a non-square result shaped like g(m) is accumulated correctly without changing existing square-matrix behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.