arXiv(opens in a new tab)cs.NEOct 2014Cited by 6 papers on PaperVantage

Manuscript Offprint

arXiv:1410.4615

Learning to Execute

Wojciech Zaremba, Ilya Sutskever

Abstract

Recurrent Neural Networks (RNNs) with Long Short-Term Memory units (LSTM) are widely used because they are expressive and are easy to train. Our interest lies in empirically evaluating the expressiveness and the learnability of LSTMs in the sequence-to-sequence regime by training them to evaluate short computer programs, a domain that has traditionally been seen as too complex for neural networks. We consider a simple class of programs that can be evaluated with a single left-to-right pass using constant memory. Our main result is that LSTMs can learn to map the character-level representations of such programs to their correct outputs. Notably, it was necessary to use curriculum learning, and while conventional curriculum learning proved ineffective, we developed a new variant of curriculum learning that improved our networks’ performance in all experimental conditions. The improved curriculum had a dramatic impact on an addition problem, making it possible to train an LSTM to add two 9-digit numbers with 99% accuracy.

1 Introduction

Execution of computer programs requires dealing with a number of nontrivial concepts. To execute a program, a system has to understand numerical operations, if-statements, variable assignments, the compositionality of operations, and many more.

We show that Recurrent Neural Networks (RNN) with Long Short-Term Memory (LSTM) units can accurately evaluate short simple programs in the sequence-to-sequence framework of Sutskever et al. (2014). The LSTM reads the program character-by-character and computes the program’s output. We consider a constrained set of computer programs that can be evaluated in linear time and constant memory, because the LSTM reads the program only once and its memory capacity is limited (Section 3).

We found it difficult to train LSTMs to execute computer programs, so we used curriculum learning to simplify the learning problem. We design a curriculum procedure which outperforms both conventional training that uses no curriculum learning (baseline) as well as the naive curriculum learning of strategy of Bengio et al. (2009) (Section 4). We provide a plausible explanation for the effectiveness of our procedure relative to naive curriculum learning (Section 7).

Finally, in addition to curriculum learning strategies, we examine two simple input transformations that further simplify the sequence-to-sequence learning problem. We show that, in many cases, reversing the input sequence (Sutskever et al., 2014) and replicating the input sequence improves the LSTM’s performance on a memorization task (Section 3.2).

The code for replicating most of the experiments in this work can be found in https://github.com/wojciechz/learning_to_execute.

References (24)