Skip to main content
QUICK REVIEW

[Paper Review] rnn : Recurrent Library for Torch

Nicholas Léonard, Sagar Waghmare|arXiv (Cornell University)|Nov 24, 2015
Reinforcement Learning in RoboticsComputer Science12 references27 citations
TL;DR

This paper introduces the rnn package, a modular, extensible library for implementing diverse Recurrent Neural Networks (RNNs) in Torch7, leveraging object-oriented design to unify RNN components under the nn package's Module and Criterion interfaces. It enables training of complex models like stacked LSTMs and recurrent attention mechanisms, reproducing state-of-the-art results on Penn Tree Bank and MNIST with improved performance over existing implementations.

ABSTRACT

The rnn package provides components for implementing a wide range of Recurrent Neural Networks. It is built withing the framework of the Torch distribution for use with the nn package. The components have evolved from 3 iterations, each adding to the flexibility and capability of the package. All component modules inherit either the AbstractRecurrent or AbstractSequencer classes. Strong unit testing, continued backwards compatibility and access to supporting material are the principles followed during its development. The package is compared against existing implementations of two published papers.

Motivation & Objective

  • To provide a flexible, reusable, and extensible library for implementing various Recurrent Neural Network architectures within the Torch7 framework.
  • To ensure backward compatibility and seamless integration with the existing nn package's training pipeline, including backpropagation and optimization.
  • To support complex RNN models such as stacked LSTMs and recurrent attention mechanisms (RAM) without relying on external libraries like nngraph.
  • To maintain strong software engineering practices, including comprehensive unit testing, documentation, and tutorials, to lower the barrier to entry for researchers.

Proposed method

  • The package implements a hierarchy of classes inheriting from AbstractRecurrent or AbstractSequencer, enabling modular and composable RNN construction.
  • It uses object-oriented programming in Lua to encapsulate recurrent cell logic, parameter sharing, and sequential application across time steps.
  • Core components like Recurrent, LSTM, and RecurrentAttention modules are designed to conform to the nn package’s Module and Criterion interfaces for compatibility with standard training loops.
  • The library supports both CPU and GPU computation via Torch’s cutorch and cunn packages, enabling efficient training on modern hardware.
  • Custom extensions were implemented in Lua to override core nn package behaviors (e.g., Module:type()), preserving parameter sharing during type casting.
  • The implementation was validated by reproducing results from two published papers: one on RNN regularization and another on visual attention.

Experimental results

Research questions

  • RQ1How can a general-purpose, modular RNN library be designed within the Torch7 ecosystem to support diverse architectures while maintaining compatibility with existing training pipelines?
  • RQ2To what extent can the rnn package reproduce or improve upon published SOTA results on standard benchmarks like Penn Tree Bank and MNIST?
  • RQ3What software engineering principles—such as backward compatibility, unit testing, and extensibility—can be applied to ensure long-term maintainability of an RNN library?
  • RQ4Can a pure-Torch implementation of complex RNNs (e.g., RAM) outperform or match implementations relying on external libraries like nngraph?

Key findings

  • The rnn package successfully reproduced the results of the Recurrent Neural Network Regularization paper, achieving test set perplexities of 83 (with dropout) and 115 (without), matching the original paper’s performance.
  • The implementation of the recurrent attention model (RAM) surpassed the original paper’s results, achieving 0.85% error on MNIST and 1.14% error on Translated MNIST, compared to 1.07% and 1.22% reported in the paper.
  • The library demonstrated strong backward compatibility, allowing existing scripts to function without modification despite internal architectural refinements.
  • The package enabled efficient training of stacked LSTM models using standard optimization routines from the optim or dp packages, confirming its integration with the broader Torch ecosystem.
  • The use of Lua’s dynamic metatable system allowed for safe and effective extension of core nn package behaviors, such as preserving parameter sharing during type casting.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.