Skip to main content

Sequences

Data often arrive as streams. A weather station reports sensor readings indexed by time, an exchange reports a stream of trades, and a reader takes in a text one word after another. To fit a model to sequential data you need a hypothesis set that is rich enough for tasks that require some form of memory. In what follows, tt is the index of a sequence element. It does not have to mean time. A dynamical system is one such rich model. Its state evolves by a recurrence: st=ft(st−1,at;θt)\mathbf{s}_t = f_t(\mathbf{s}_{t-1}, \mathbf{a}_t ; \boldsymbol{\theta}_t) Here s\mathbf s is the evolving state, a\mathbf a is an external action or control, and θ\boldsymbol\theta is a set of parameters that specify the state evolution model ff. This short equation can capture a lot of complexity, because three things are allowed to change with tt:
  1. The state space, the set of possible states.
  2. The action space, the set of possible actions.
  3. The function that maps the previous state and the action to a new state.

RNN architecture

A recurrent neural network (RNN) is a constrained version of this dynamical system: ht=f(ht−1,xt;θ)\mathbf{h}_t = f(\mathbf{h}_{t-1}, \mathbf{x}_t ; \boldsymbol{\theta}) The RNN applies the same function, with the same parameters θ\boldsymbol\theta, at every step of the sequence 1:τ1:\tau. The state is latent, and it is written h\mathbf h to match the notation for hidden layers in feed-forward networks. Because θ\boldsymbol\theta does not depend on tt, the network shares its parameters across the sequence. CNNs share parameters too, but only over the small span of a filter. The larger difference between the two is the recurrence itself. An RNN cell whose hidden state feeds back into itself through a delay Recursive state representation in RNNs The hidden activations h\mathbf h of a CNN do not depend on earlier hidden activations, so a CNN cannot remember previous inputs when it solves a classification or regression task. An RNN remembers through its hidden state, and you choose the size of that state to suit the task. This memory is the main feature that sets the RNN apart. A feed-forward network can get a limited memory from a sliding window over the input, as the figure below shows for a language task. A feed-forward network that concatenates the embeddings of the last three words to predict the next word A feed-forward network can model sequential data, here for language modeling. At each step tt, a sliding window of span τ=3\tau=3 acts as memory: the network concatenates the word embeddings in the window and uses a hidden layer h\mathbf h to predict the next element of the sequence. The span is limited and fixed. Words such as “the ground” also appear in several windows, so the network has to learn two different patterns for the same phrase (“in the ground” and “the ground there”). RNNs come in many arrangements of inputs and outputs. Five input-output arrangements, from one-to-one to many-to-many with and without delay From left to right: a CNN, image captioning, sentiment classification, machine translation, and multi-object tracking. RNNs can work with input and output sequences of variable length.

PyTorch reference

Key references: (Lipton et al., 2015; Schmidhuber, 2015; Graves et al., n.d.; Li et al., 2015; Chung et al., 2015)

References

  • Chung, J., Kastner, K., Dinh, L., Goel, K., Courville, A., et al. (2015). A Recurrent Latent Variable Model for Sequential Data. arXiv [cs.LG]. Link
  • Graves, A., Wayne, G., Danihelka, I. (n.d.). Neural Turing Machines. Link
  • Li, X., Li, L., Gao, J., He, X., Chen, J., et al. (2015). Recurrent Reinforcement Learning: A Hybrid Approach. arXiv [cs.LG]. Link
  • Lipton, Z., Berkowitz, J., Elkan, C. (2015). A Critical Review of Recurrent Neural Networks for Sequence Learning. arXiv [cs.LG]. Link
  • Schmidhuber, J. (2015). On Learning to Think: Algorithmic Information Theory for Novel Combinations of Reinforcement Learning Controllers and Recurrent Neural World Models. arXiv [cs.AI]. Link

Found an error on this page? Report an issue.