DyNet Examples

This is a set of common (and less common) models and their implementation in Dynet (C++ and Python).

Some examples have only one of the two languages, or lack documentation, in which case we welcome contributions for the other. Documentation should include directions on how to download standard datasets, run these examples on these datasets, and calculate standard measures of accuracy etc. A good example of a simple README is in the mnist directory. Contributions to adding these are welcome!

Note that these examples are meant to be minimal examples, not necessarily the state of the art. Concurrently, we are working on creating a state-of-the-art model repository. In the mean time, you can browse the many research projects that use DyNet and find one that fits your needs.

Main Model Examples

These examples are of common models and are intended to be relatively well maintained.

  • XOR: The simplest possible model, solving xor (C++/Python).
  • MNIST: An example of MNIST image classification using a simple multi-layer perceptron (C++).
  • RNN Language Model: A recurrent neural network language model (C++/Python).
  • Sequence-to-sequence Model: Sequence to sequence models using standard encoder decoders, or attention (C++/Python).
  • BiLSTM Tagger: Models that do sequence labeling with BiLSTM feature extractors (C++/Python).
  • Text Categorization: Models for text categorization (C++/Python).
  • Word Embedding: Models for word embedding (C++).

Functionality Examples

These examples demonstrate how to take advantage of various types of functionality of DyNet.

  • Batching: How to use mini-batch training (C++/Python).
  • Automatic Batching: How to use DyNet’s automatic batching functionality (C++).
  • Devices: How to use DyNet on CPUs, GPUs, or multiple devices (C++/Python).
  • Multiprocessing: DyNet’s multiprocessing functionality for training models in parallel (C++).
  • TensorBoard: How to use DyNet with TensorBoard through PyCrayon (Python).
  • Reading/Writing: How to read/write models (C++).
  • Jupyter Tutorials: Various tutorials in the form of Jupyter notebooks (Python).

Auxiliary Model Examples

These are somewhat less common and not necessarily well supported, but still may be useful for some people.