This repository contains a Python implementation of npde - a nonparametric model for learning unknown differential equations. Two related papers are
Also, this repository overrides the old MATLAB implementation of our ODE model, which was published along with the paper.
More details, figures and usage examples can be found in this demo notebook.
The implementation is in Python3.5, and it requires TensorFlow(1.6.0+) and GPflow(1.1+). The dependencies can be installed via
# in a python3.5 installation
pip install -r requirements.txt
Fitting our model on some data is as simple as follows:
npde = build_model(sess, t, Y, model='ode')
npde = fit_model(sess, npde, t, Y) # parameters are the TensorFlow session, time points and observations. model could be ode/sde
It is also possible to predict the future
path = npde.predict(x0,t) # x0 and t are the time points and the initial value
and sample from the learned model
samples = npde.sample(x0,t,Nw) # Nw is the number of samples
demo.ipynb
contains some more details, including three example fits where the underlying dynamics are governed by an ODE, SDE with constant diffusion, and SDE with state dependent diffusion. Below are ODE and constant diffusion fits:
The wrapper function build_model
is where the parameters, kernel, and posterior are initialized - perhaps a good starting point to read the code. Check out the following optional inputs to better understand what's what:
sf
: drift signal varianceell
: drift lengthscalesfg
: diffusion signal varianceellg
: diffusion lengthscaleW
: inducing point grid widthNw
: number of random draws used for optimizing SDEs