Skip to content

Update APF to new interface #79

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Update APF to new interface #79

wants to merge 3 commits into from

Conversation

FredericWantiez
Copy link
Member

No description provided.

@charlesknipp
Copy link
Collaborator

Love seeing this PR back in the rotation.

Instead of changing the mutability of the filter, we could instead dispatch on an Auxiliary callback.

struct AuxiliaryWeightCallback{WT} <: AbstractCallback
    log_weights::Vector{WT}
end

where we can replace update_weights! with a post update callback

function (aux::AuxiliaryWeightCallback)(
    model, algo, iter, state, observation, ::PostUpdateCallback; kwargs...
)
    aux.log_weights = map(state.particles) do particle
        logeta(particle, model, iter, observation; kwargs...)
    end
    state.log_weights += aux.log_weights
    return nothing
end

and replace reset_weights! with a post resample callback

function (aux::AuxiliaryWeightCallback)(
    model, algo, iter, state, observation, ::PostResampleCallback; kwargs...
)
    state.log_weights = state.log_weights - aux.log_weights[state.ancestors]
    return nothing
end

I haven't figured out a good way to dispatch filter with this particular callback built in, but ideally I'd still like to keep the filter(rng, model, APF(N), data) syntax. Although I'm sure it's not that difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants