Repository navigation
Trainable neural-ODE flow (FFJORD / ContinuousNormalizingFlow) - #49
Merged
Merged
Conversation
A velocity field defines an ODE from data to a Gaussian base; the exact log-density follows the instantaneous change of variables (Hutchinson trace), torch-only via fixed-step RK4 with direct backprop. Trains by max likelihood, samples in one reverse pass, doubles as a self-normalized energy. New private ebm/_ode.py holds the augmented integrator; pf_ode_log_likelihood reuses its probe sampler. Validated: linear-field closed form + exact rotation invariance.
Merged
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.
Trainable neural-ODE flow — FFJORD (0.15.0)
The second flagship:
nets.ContinuousNormalizingFlow, the trainable generalization of the eval-onlypf_ode_log_likelihoodshipped earlier. A neural velocity fieldv_θ(x, t)defines an ODE from data (t=0) to aN(0, I)base (t=1); the exact log-density follows the instantaneous change of variablesd log p/dt = -tr(∂v/∂x), with the divergence estimated by Hutchinson. Pure torch — fixed-step RK4 with direct backprop (no adjoint, no torchdiffeq). Trains by maximum likelihood, samples in one reverse pass, and doubles as a self-normalized energy (forward(x) = -log_prob(x),log Z = 0).A new private
ebm/_ode.pyholds the augmented integrator + Hutchinson probe sampler;pf_ode_log_likelihoodnow reuses the shared probe sampler.Validation:
v = xAᵀ: the flow mapsx → e^A xwithlog|det| = tr(A), solog p(x) = log N(e^A x) + tr(A)— the mean matches (error 0.003, Hutchinson is unbiased).tr = 0exactly (εᵀSε = 0) and the base Gaussian is rotation-invariant, solog_prob(x) == log N(x; 0, I)to 1e-5.Example
train_cnf.py(two-moons, exact density by ODE). Lands under unreleased 0.15.0 (alongside the cleanup + VP diffusion).Verification
ruff + format + mypy clean; 163 tests pass; example runs on CPU (~2.5 min).
🤖 Generated with Claude Code