Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@felixzinn
Copy link
Contributor

in the calculation of the poisson term of the likelihood function the sum has to be taken before the constraints are added with loss_val += evm.util.sum_over_leaves(constraints) because Poisson.log_prob returns a multi-dimensional array with the same shape as observation

so it has to be

@eqx.filter_jit
def loss(dynamic_model, static_model, hists, observation):
    model = eqx.combine(dynamic_model, static_model)
    expectations = model(hists)
    constraints = evm.loss.get_log_probs(model)
    loss_val = (
        evm.pdf.Poisson(evm.util.sum_over_leaves(expectations))
        .log_prob(observation)
        .sum()
    )
    # add constraint
    loss_val += evm.util.sum_over_leaves(constraints)
    return -jnp.sum(loss_val)

changed in the documentation and examples

@pfackeldey
Copy link
Owner

Thanks 👍

@pfackeldey pfackeldey merged commit e863f9a into pfackeldey:main Feb 3, 2025
3 checks passed
@felixzinn felixzinn deleted the fix/examples branch February 17, 2025 15:09
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