Skip to content
Go to file


Failed to load latest commit information.

Deep Markov Models


This repository contains theano code for implementing Deep Markov Models. The code is documented and should be easy to modify for your own applications.

Deep Markov Model

The code uses variational inference during learning to maximize the likelihood of the observed data:

Evidence Lower Bound

  • Generative Model
    • The figure depicts a state space model for time-varying data.
    • The latent variables z1...zT and the observations x1...xT together describe the generative process for the data.
    • The emission p(x_t|z_t) and transition functions p(z_t|z_{t-1}) are parameterized by deep neural networks
  • Inference Model
    • The function q(z1..zT | x1...xT) represents the inference network
    • This is a parametric approximation to the variational posterior used for learning at training time and for inference at test time.


This package has the following requirements:

  • python2.7
  • Theano
    • Used for automatic differentiation
  • theanomodels
    • Wrapper around theano that takes care of bookkeeping, saving/loading models etc. Clone the github repository and add its location to the PYTHONPATH environment variable so that it is accessible by python.
  • An NVIDIA GPU w/ atleast 6G of memory is recommended.


I used the following ~/.theanorc configuration file:





You can change whether the model is run on the GPU or CPU by modifying the THEANO_FLAGS. See here for documentation.


  • Model Code: model_th: This folder contains raw theano code implementing the model. See the folder for details on how the DMM was implementation and pointers to portions of the code.
  • Datasets: dmm_data: This folder contains code to load the polyphonic music data and a synthetic dataset. Add or change code in to run the model on your own data.
  • Tutorials: ipynb: This folder contains some IPython notebooks with examples on loading and running the model on your own data.
  • Hyperparameters: This file contains hyperparameters used by the model. Run python -h for an explanation of what the various choices of parameters change in the generative model and inference network.
  • Modeling Polyphonic Music: expt: Experimental setup for running the DMM on the polyphonic music dataset
  • Template Folder for Training DMMs: expt_template : Experimental setup for running the DMM on synthetic real-valued observations.

Running the model on your data

  • A general purpose tutorial for setting up and running the model can be found in the IPython Notebooks.
  • The code currently supports binary and real-valued data. An example of modeling binary data may be found in expt/.


Please cite the following paper if you find the code useful in your research:

  title={Structured Inference Networks for Nonlinear State Space Models},
  author={Krishnan, Rahul G and Shalit, Uri and Sontag, David},

This paper subsumes the work in : [Deep Kalman Filters] (


No releases published


No packages published


You can’t perform that action at this time.