OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

Contrastive Predictive Coding

A Python repository implementing Contrastive Predictive Coding in Keras. It trains an encoder to represent sequential data by predicting future patterns in a latent space and distinguishing valid from invalid sequences; the encoder can then supply features for downstream tasks such as supervised classification.

Independent OpenViST project profile, based on linked sources.

Contrastive Predictive Coding — Learning how CPC predicts future sequence elements from context in a latent space
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it to explore CPC training or the transition from an unsupervised sequence encoder to supervised classification, especially when the documented modified-MNIST example is relevant.

Who it is for

  • Researchers and developers exploring unsupervised representation learning for sequential data.
  • Practitioners who want to use learned encoder features in a downstream classifier.

Documented uses

  • Train an encoder to learn representations from sequences without annotations.
  • Use a frozen CPC encoder as a feature source for a supervised classification task.
  • Study a toy example of contrastive sequence training and latent-space prediction.
Before you choose

Requirements & limits

  • The documented prerequisites are specific older versions: Anaconda Python 3.5.3, Keras 2.0.6 and TensorFlow 1.4.0.
  • A GPU is noted as useful for faster training, not as a required prerequisite.
  • The repository demonstrates the method on modified-MNIST sequences; using another sequential dataset is a likely-compatible adaptation, not a demonstrated workflow.
  • The repository evidence identifies no license.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Train CPC and benchmark its encoder on the included example

Run the documented training and downstream classification stages using the modified-MNIST sequence example.

Before you start

  • Anaconda Python 3.5.3
  • Keras 2.0.6
  • TensorFlow 1.4.0
  • A GPU for faster training

Steps

  1. Run the command below to train the CPC model.

    Documented command
    python train_model.py
  2. Run the command below to train an MLP on top of the CPC encoder.

    Documented command
    python benchmark_model.py

Expected outcome

The repository describes training CPC and then training an MLP classifier using the encoder on the same example data.

Guide limitations

  • The documented dataset is a toy set of modified-MNIST sequences, not a general dataset setup guide.
  • The README provides no guarantee of results and describes the code as provided as is.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
10 November 2026
Original website title
davidtellez/contrastive-predictive-coding · Official homepage title · retained in its source language