Skip to content
fn

neural_ode

→NeuralODEModel
neural_ode(pretrained: bool = False, overrides: object = {})

Construct the Neural ODE continuous normalizing flow.

A single vector field integrated from t = 0 to t = 1, with the log-density carried alongside it by the instantaneous change of variables. Depth is not a hyper-parameter: lucid.diffeq spends as many evaluations as the requested tolerance needs, and nfe reports how many that was.

Model Size

Parameters

pretrainedbool= False
No checkpoint is published for neural_ode, so True raises NotImplementedError rather than return randomly initialised weights.
**overridesobject= {}
Optional NeuralODEConfig field overrides forwarded into the underlying config.

Returns

NeuralODEModel

Bare flow configured with the paper's M=64M = 64 field and any overrides.

Notes

Reference: Chen, Rubanova, Bettencourt, and Duvenaud, "Neural Ordinary Differential Equations", NeurIPS, 2018 (arXiv:1806.07366), §4. The paper's own continuous-flow experiments are two-dimensional density matching, where the trace of the Jacobian is summed exactly; at the image shape this factory defaults to, the same flow switches to the Hutchinson estimator of Grathwohl et al. (FFJORD, ICLR 2019), which is what makes the cost independent of the dimension.

Examples

>>> import lucid
>>> from lucid.models.generative.neural_ode import neural_ode
>>> model = neural_ode(sample_size=(1, 2), in_channels=1,
...                    out_channels=1).eval()
>>> z, log_det = model.encode(lucid.rand((2, 1, 1, 2)))
>>> z.shape, log_det.shape
((2, 2), (2,))
>>> model.trace_method            # two-dimensional, so exact
'exact'

Used by 1