Skip to content

Sequences, streaming data, robotics, and scientific extensions · Entry index · SEQ003 · Model

Neural controlled differential equation (Neural CDE)

A continuous-time sequence model whose hidden state is driven by an interpolated observation path. It handles irregular measurements by separating the observed control path from learned hidden dynamics.

Runs in CodeSplash (Experimental) Component demo, not a trained model CodeSplash's own run

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Availability
Runs in CodeSplash (Experimental)
Code example
Component demo, not a trained model
Who ran it
CodeSplash's own run
CodeSplash's run
Verified in Python and R through learn.neural_cde. The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review, but on a different version of the code. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

A continuous-time sequence model whose hidden state is driven by an interpolated observation path. It handles irregular measurements by separating the observed control path from learned hidden dynamics. This is a predictive architecture, not merely an ordinary neural ODE evaluated at irregular times.

Question / hypotheses

Can hidden-state evolution use the values and timing of partially observed measurements without pretending they are uniformly sampled? There is no intrinsic H0/H1; compare predictive accuracy, interpolation sensitivity, and solver behavior.

Architecture / computational structure

Observed samples become a continuous control representation; a controlled differential equation updates latent state, and a task head reads it. A piecewise linear control gives a simple teaching approximation, while production training may use smoother interpolation and adjoint differentiation.

Assumptions

Construct a meaningful control path from measurements, often including time and observation indicators. Interpolation choices are modeling assumptions; some interpolation schemes use future points and are unsuitable for an online causal claim. Observed timing may itself carry information about the data-generating process.

Formula / computational definition

zt=zt0+∫t0tfθ(zs) dXsz_t=z_{t_0}+\int_{t_0}^{t}f_\theta(z_s)\,dX_s. Here XsX_s is the interpolated multichannel control, zsz_s the hidden state, and fθf_\theta maps hidden states to matrices acting on control increments. Initialization and readout map observations to zt0z_{t_0} and predictions.

Parameters and notation

Learned parameters: vector-field network, initialization, and task readout. Hyperparameters: hidden dimension, control channels, interpolation, solver/tolerances, and loss. A tighter numerical tolerance changes integration accuracy/cost, not the amount of statistical information or the predictive distribution’s calibration.

Fitting, fine-tuning, and adaptation

Fit initialization/vector-field/readout together under the downstream loss. For transfer, adapt the readout first, then cautiously unfreeze dynamics while preserving the control-channel definitions. Tune interpolation and solver accuracy on development tasks; reassess online causality when changing interpolation.

How to use and calibrate

Compare with time-aware discrete baselines on matched irregular samples. Plot prediction sensitivity to missing channels, observation density, time perturbations, and numerical tolerances. Separate solver error from generalization error and test longer gaps than those seen in training.

Example application

Classify a known dynamical trajectory observed at irregular intervals and demonstrate how a timestamp channel changes hidden-state updates.

Interpretation / pitfalls

Watch out

Python: the authors’ NeuralCDE/torchcde ecosystem or custom controlled integration. R: reticulate to the same implementation; base R can illustrate an Euler control increment. The example is one fixed-field update, not neural training or a full CDE solver.

Python and R code examples (dependencies/validation)

Python uses NumPy and the shared mse helper when called; base R uses the shared helper when called. Validation: Python component executed; R companion reviewed, not executed. Scope: the specific component described above, not the full model or its training.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — synthetic mathematical component, not a full-model implementation

Shared setup for this chapter
import numpy as np

def mse(a,b):
    a,b=np.asarray(a),np.asarray(b)
    if a.shape!=b.shape or a.size==0:
        raise ValueError("MSE needs nonempty equal shapes")
    return float(np.mean((a-b)**2))
z=np.array([.2,-.1]); field=np.array([[1.,.3],[-.2,.5]])
control_increment=np.array([.4,.2])
result=z+field@control_increment
print(result)
R

Component demo, not a trained model — synthetic mathematical component, not a full-model implementation

Shared setup for this chapter
mse <- function(a,b) {
  stopifnot(length(a)>0L, identical(dim(a),dim(b)), length(a)==length(b))
  mean((a-b)^2)
}
z <- c(.2,-.1); field <- rbind(c(1,.3),c(-.2,.5)); control_increment <- c(.4,.2)
result <- as.vector(z+field%*%control_increment)
print(result)

Sources

From the CodeSplash reference, entry SEQ003.