Repository navigation
Add foundation types and renames for NN Builder refactor - #1872
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1872 +/- ##
==========================================
+ Coverage 87.89% 87.92% +0.03%
==========================================
Files 143 144 +1
Lines 13353 13403 +50
==========================================
+ Hits 11736 11785 +49
- Misses 1617 1618 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
cd4f349 to
d31f0cf
Compare
janfb
left a comment
There was a problem hiding this comment.
Thanks a lot @satwiksps for this clean PR! it's great to receive these well-scoped PR.
As discussed in our meeting, I added a couple of comments and suggestions. Let me know if you have any questions.
| structured = config.theta == "structured" | ||
| theta_mean, theta_std = z_standardization(theta, structured) |
There was a problem hiding this comment.
to make this and the one below more readable, I suggest to make the kwarg explicit and do it in one line:
if config.theta != "none":
theta_mean, theta_std = z_standardization(
theta, structured_dims=(config.theta == "structured")
)
janfb
left a comment
There was a problem hiding this comment.
Looks perfect! thanks for addressing my suggestion so precisely and in separate commits 🙌 🙏
* rename ConditionalEstimatorBuilder to ConditionalEstimatorBuildFn * add ZScoreConfig, ZScoreStats, BuildContext, and compute_z_score_stats * rename _EstimatorConfigBase to _EstimatorBuilderBase and add build() * add tests for builder foundation types and renames * pre-commit fix * rename ConditionalEstimatorBuilder in npe_pfn.py * add warning * some docstrings and coding style improvements * major changes in test file * minor docstring styling fix
What does this PR do?
This PR sets up the groundwork for the Neural Network (NN) Builder refactor project under GSoC 2026. It doesn't add the final builders yet, but it provides a clean, reviewable foundation for the upcoming PRs.
Here are the main changes:
New
build_context.pyFile:Adds the core pieces needed to set up a neural network:
ZScoreConfig: Tracks how the user wants to preprocess data (e.g., "none", "independent", "structured").ZScoreStats: Holds the calculated mean and standard deviation.BuildContext: Bundles everything needed to build network (shapes, device, dtype, and z-score stats) into one place.compute_z_score_stats(): A simple helper function to calculate the z-score stats from the data.Renamed
ConditionalEstimatorBuildertoConditionalEstimatorBuildFn:Renamed
_EstimatorConfigBaseto_EstimatorBuilderBase:build()method to it.from_kwargs()andto_dict()methods are untouched and work as usual.Files Changed
sbi/neural_nets/build_context.py(NEW): AddedZScoreConfig,ZScoreStats,BuildContext, andcompute_z_score_statsas suggested in updated plan.mdsbi/neural_nets/estimators/base.py: RenamedConditionalEstimatorBuildertoConditionalEstimatorBuildFnsbi/neural_nets/net_builders/estimator_configs.py: Renamed_EstimatorConfigBaseto_EstimatorBuilderBaseand added an emptybuild()methodsbi/neural_nets/net_builders/vector_field_nets.py: Updated imports and docstringsnpe/,nle/,nre/,vfpe/): Updated Protocol imports across 16 filestests/build_context_test.py(NEW): Added 26 passing tests to fully cover the new types, much of these codes in this file is suggested by AI, we can trim out if any tests are unnecessaryAI Usage
build_context_test.py.Does this close any issues?
N/A
Any relevant code examples, logs, or error messages?
N/A