You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was diabled because naive z-scoreing as input layer can have very negative consequence performancewise. This however can be done similar to how it is done in NPSE with access to the time-dependent moments.
For the simple FM we have implemented with $\mu_0=0$ and $\sigma_0=1$, $\mu_1 = \text{theta.mean(0))}$ and $\sigma_1 = \text{theta.std(0)}$ this should be given by $$\mu_t = t\mu_1$$
and $$\sigma_t = \sqrt{t^2 \sigma_1^2 + (1-t)^2 }$$
Z-scoreing can then be doen automatically as for all the other estimators.
I plan to re-introduce z-scoring for Flow Matching using the time-dependent moments as suggested. Here is my proposed implementation plan:
Mathematical Approach
To avoid the issues with naive z-scoring at $t=0$, I will interpolate the normalization statistics based on time $t$:
$$\mu_t = t \cdot \mu_{data}$$$$\sigma_t = \sqrt{t^2 \sigma_{data}^2 + (1-t)^2}$$
Implementation Details
Builder (vector_field_nets.py): Update build_vector_field_estimator to capture the training data statistics (mean and std) and pass them into the FlowMatchingEstimator constructor as mean_1 and std_1.
Estimator (flowmatching_estimator.py):
Register mean_1 and std_1 as buffers.
In the forward pass, calculate $\mu_t$ and $\sigma_t$ dynamically.
Normalize the input: $\hat{\theta}_t = (\theta_t - \mu_t) / \sigma_t$.
Crucially: Rescale the output vector field $v$ by $\sigma_t$ to ensure the ODE integration remains consistent with the original scale.
Testing: Add an integration test in linearGaussian_vector_field_test.py to verify that z_score_x='structured' correctly registers these buffers and that the forward pass executes without shape mismatches.
I have verified this logic locally and confirmed that the statistics are learned correctly. Does this align with your vision? If so, I am ready to open a PR.
To check on any performance implications, would be good to run pytest --bm --bm-mode fmpe for a quick check.
Crucially: Rescale the output vector field
Agree, the "preconditioning" of the network can help! At t=0 the optimal prediction is the base distribution mean (i.e. 0). Not sure what scaling you had in mind (i.e. there are quite a few options e.g. based on Gaussian assumptions) but happy for anything if it helps.
Activity
satwiksps commentedon Jan 25, 2026
Hi @manuelgloeckler @janfb , I would like to pick up this issue.
I plan to re-introduce z-scoring for Flow Matching using the time-dependent moments as suggested. Here is my proposed implementation plan:
Mathematical Approach
To avoid the issues with naive z-scoring at$t=0$ , I will interpolate the normalization statistics based on time $t$ :
Implementation Details
vector_field_nets.py): Updatebuild_vector_field_estimatorto capture the training data statistics (meanandstd) and pass them into theFlowMatchingEstimatorconstructor asmean_1andstd_1.flowmatching_estimator.py):mean_1andstd_1as buffers.forwardpass, calculatelinearGaussian_vector_field_test.pyto verify thatz_score_x='structured'correctly registers these buffers and that the forward pass executes without shape mismatches.I have verified this logic locally and confirmed that the statistics are learned correctly. Does this align with your vision? If so, I am ready to open a PR.
manuelgloeckler commentedon Feb 2, 2026
Dear @satwiksps,
this sounds good! Happy to accept a PR on this.
To check on any performance implications, would be good to run
pytest --bm --bm-mode fmpefor a quick check.Agree, the "preconditioning" of the network can help! At
t=0the optimal prediction is the base distribution mean (i.e. 0). Not sure what scaling you had in mind (i.e. there are quite a few options e.g. based on Gaussian assumptions) but happy for anything if it helps.Kind regards,
Manuel