/prednet

Code and models accompanying "Deep Predictive Coding Networks for Video Prediction and Unsupervised Learning"

Primary LanguagePythonMIT LicenseMIT

prednet

Code and models accompanying Deep Predictive Coding Networks for Video Prediction and Unsupervised Learning by Bill Lotter, Gabriel Kreiman, and David Cox.

The PredNet is a deep recurrent convolutional neural network that is inspired by the neuroscience concept of predictive coding (Rao and Ballard, 1999; Friston, 2005). Check out example prediction videos here.

The architecture is implemented as a custom layer1 in Keras. It is compatible with both theano and tensorflow backends. Tested on Keras 1.2.1 with Theano 0.9.0, Tensorflow 0.12.1, and Python 2.7. See http://keras.io/ for instructions on installing Keras and its list of dependencies. For Torch implementation, see torch-prednet.

KITTI Demo

Code is included for training the PredNet on the raw KITTI dataset. We include code for downloading and processing the data, as well as training and evaluating the model. The preprocessed data and can also be downloaded directly using download_data.sh and the trained weights by running download_models.sh. The model download will include the original weights trained for t+1 prediction, the fine-tuned weights trained to extrapolate predictions for multiple timesteps, and the "Lall" weights trained with an 0.1 loss weight on upper layers (see paper for details).

Steps

  1. Download/process data

    python process_kitti.py

    This will scrape the KITTI website to download the raw data from the city, residential, and road categories (~165 GB) and then process the images (cropping, downsampling). Alternatively, the processed data (~3 GB) can be directly downloaded by executing download_data.sh

  2. Train model

    python kitti_train.py

    This will train a PredNet model for t+1 prediction. See Keras FAQ on how to run using a GPU. To download pre-trained weights, run download_models.sh

  3. Evaluate model

    python kitti_evaluate.py

    This will output the mean-squared error for predictions as well as make plots comparing predictions to ground-truth.

Feature Extraction

Extracting the intermediate features for a given layer in the PredNet can be done using the appropriate output_mode argument. For example, to extract the hidden state of the LSTM (the "Representation" units) in the lowest layer, use output_mode = 'R0'. More details can be found in the PredNet docstring.


1 Note on implementation: PredNet inherits from the Recurrent layer class, i.e. it has an internal state and a step function. Given the top-down then bottom-up update sequence, it must currently be implemented in Keras as essentially a 'super' layer where all layers in the PredNet are in one PredNet 'layer'. This is less than ideal, but it seems like the most efficient way as of now. We welcome suggestions if anyone thinks of a better implementation.