Add DensityEstimatorBuilder with build() dispatch#1877
Draft
satwiksps wants to merge 16 commits into
Draft
Conversation
Contributor
Author
|
This is a stacked PR, so opening as a Draft. Once the PR #1872 is merged into a new GSoC specific branch, I will rebase this branch and mark it Ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This is the second PR for for the Neural Network (NN) Builder API refactor project under GSoC 2026. It adds
DensityEstimatorBuilderwhich is the first concrete builder class in the NN builder refactor. It provides a typed, inspectable replacement for theposterior_nn()/likelihood_nn()factory closures, covering all 14 continuous density estimator model types.Builds on PR #1872 which introduced
BuildContext,ZScoreConfig,ZScoreStats, and the_EstimatorBuilderBasecontract.Files Changed
sbi/neural_nets/net_builders/estimator_configs.pyDensityEstimatorBuilder(_EstimatorBuilderBase)dataclass with:model: Literal[...]field selecting the architecture (maf, nsf, mdn, made, maf_rqs, and all Zuko variants)__post_init__validation: unknown model names fail immediately at constructionbuild(context, batch_theta, batch_x): dispatches to the appropriate existingbuild_*function_build_kwargs(): collects non-None fields + extra_kwargs, excludingmodel(used only for dispatch)DENSITY_MODELStype alias and_VALID_DENSITY_MODELSset for validationsbi/neural_nets/net_builders/__init__.pyDensityEstimatorBuildertests/density_estimator_builder_test.py(created new file, or may be we can also add to existing test files ?)AI Usage
Does this close any issues?
N/A
Any relevant code examples, logs, or error messages?
N/A