Skip to content
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

Add a demo model with matrix assume + individual indexing x[i][j] / tuple indexing x[i, j] #748

Open
penelopeysm opened this issue Dec 12, 2024 · 2 comments

Comments

@penelopeysm
Copy link
Member

See: #733 (comment)

When refactoring the demo models into a separate package, we should include one that has this as well.

@penelopeysm
Copy link
Member Author

(There's demo_assume_matrix_dot_observe_matrix, but it doesn't test with indexing on the LHS of a tilde)

@model function demo_assume_matrix_dot_observe_matrix(
    x=transpose([1.5 2.0;]), ::Type{TV}=Array{Float64}
) where {TV}
    n = length(x)
    d = n ÷ 2
    s ~ reshape(product_distribution(fill(InverseGamma(2, 3), n)), d, 2)
    s_vec = vec(s)
    m ~ MvNormal(zeros(n), Diagonal(s_vec))

    # Dotted observe for `Matrix`.
    x .~ MvNormal(m, Diagonal(s_vec))

    return (; s=s, m=m, x=x, logp=getlogp(__varinfo__))
end

@yebai
Copy link
Member

yebai commented Dec 16, 2024

Thanks, @penelopeysm; a quick thought: it might be helpful t to have separate sets of models in DynamicPPL.TestModels

  • for testing the DynamicPPL compiler
  • for testing inference algorithm correctness, e.g. models with analytical solutions or known solutions stored as constants
  • for testing autograd and log density performance, type stability, etc.

Each set of models can be retrieved by, e.g. DynamicPP.TestModels.models_for_compiler_tests / models_for_inference_correctness_tests, models_for_performance_autograd_tests.

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

No branches or pull requests

2 participants