Recurrent Neural Networks (1995) › The Mathematics of Sequential Processing

Michael BrenndoerferMarch 9, 20253 min read
History of Language AIAll chapters
Part 2 of 9The Statistical Turn
Chapter 26Recurrent Neural Networks (1995) › The Mathematics of Sequential Processing
Reading section 4 of 11 · The Mathematics of Sequential Processing · 3 minSection 4 of 11 · 3 min

Book contents

Section 4 of 11 · 3 min read

Recurrent Neural Networks (1995) › The Mathematics of Sequential ProcessingOne section · Sections in this chapter4 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

While the conceptual idea behind RNNs is straightforward, understanding the mathematics reveals how they process sequences and learn from data. The core operation of an RNN can be expressed in a simple form: at each time step, the network takes the current input and the previous hidden state, combines them through a learned transformation, and produces both a new hidden state and an output.

Let us denote the hidden state at time step tt as hth_t, the current input as xtx_t, and the output at time tt as oto_t. The RNN updates its hidden state using the following equation:

ht=f(U⋅xt+V⋅ht−1+bh)h_t = f(U \cdot x_t + V \cdot h_{t-1} + b_h)

Here, UU is a weight matrix that transforms the current input xtx_t, and VV is a weight matrix that transforms the previous hidden state ht−1h_{t-1}. The term bhb_h is a bias term that allows the network to shift its activations. The function ff is an activation function, typically the hyperbolic tangent tanh or the logistic sigmoid σ\sigma, which introduces nonlinearity into the transformation. This nonlinearity allows the network to learn complex patterns that linear functions cannot capture.

Once the hidden state is computed, the network produces an output using a second transformation:

ot=g(W⋅ht+bo)o_t = g(W \cdot h_t + b_o)

In this equation, WW is a weight matrix that maps the hidden state to the output space, and bob_o is another bias term. The function gg is typically a softmax function when the output represents a probability distribution over discrete outcomes, such as predicting the next word in a vocabulary, or a linear function for continuous outputs.

One of the most important features of this formulation is that the weight matrices UU, VV, and WW are shared across all time steps. This means that the same parameters are used to process every element of the sequence, regardless of its position. This weight sharing serves two purposes. First, it dramatically reduces the number of parameters in the model, making it feasible to train on sequences of varying lengths without needing a different set of weights for each position. Second, it enables the network to generalize patterns learned at one time step to other time steps, which is essential for tasks like language modeling where the same grammatical structures can appear anywhere in a sentence.

The process of computing the hidden state at each time step is often called recurrent step or the forward pass through time. When we process an entire sequence, we repeatedly apply these equations, starting from an initial hidden state h0h_0 (which is often initialized to zeros) and stepping forward through the sequence one element at a time. This sequential processing is both the strength and the weakness of RNNs. It allows them to build up a representation of context over time, but it also means that processing long sequences can be slow, since each step depends on the previous one and cannot be computed in parallel.