GRU Architecture › GRU Parameter Efficiency

Michael BrenndoerferMay 14, 20254 min read
Language AI HandbookAll chapters
Part 11 of 67Recurrent Neural Networks
Chapter 80GRU Architecture › GRU Parameter Efficiency
Reading section 7 of 15 · GRU Parameter Efficiency · 4 minSection 7 of 15 · 4 min

Book contents

Section 7 of 15 · 4 min read

GRU Architecture › GRU Parameter EfficiencyOne section · Sections in this chapter7 / 15 ↓
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

One of the GRU's main selling points is its reduced parameter count compared to LSTMs. Let's quantify this difference precisely.

For a single-layer recurrent network with input size dd and hidden size hh, each gate or transformation requires:

  • A weight matrix WW of shape (h,d+h)(h, d + h), contributing (d+h)×h(d + h) \times h parameters
  • A bias vector bb of shape (h,)(h,), contributing hh parameters
  • Total per gate: (d+h)×h+h(d + h) \times h + h parameters

LSTM parameters (4 gates/transformations):

  • Forget gate: (d+h)×h+h(d + h) \times h + h parameters
  • Input gate: (d+h)×h+h(d + h) \times h + h parameters
  • Cell candidate: (d+h)×h+h(d + h) \times h + h parameters
  • Output gate: (d+h)×h+h(d + h) \times h + h parameters
  • Total: 4×[(d+h)×h+h]=4h2+4dh+4h4 \times [(d + h) \times h + h] = 4h^2 + 4dh + 4h

GRU parameters (3 gates/transformations):

  • Reset gate: (d+h)×h+h(d + h) \times h + h parameters
  • Update gate: (d+h)×h+h(d + h) \times h + h parameters
  • Candidate: (d+h)×h+h(d + h) \times h + h parameters
  • Total: 3×[(d+h)×h+h]=3h2+3dh+3h3 \times [(d + h) \times h + h] = 3h^2 + 3dh + 3h

The ratio of GRU to LSTM parameters is:

GRU paramsLSTM params=3h2+3dh+3h4h2+4dh+4h=3(h2+dh+h)4(h2+dh+h)=34=75%\frac{\text{GRU params}}{\text{LSTM params}} = \frac{3h^2 + 3dh + 3h}{4h^2 + 4dh + 4h} = \frac{3(h^2 + dh + h)}{4(h^2 + dh + h)} = \frac{3}{4} = 75\%

The GRU has exactly 75% of the LSTM's parameters, regardless of the input and hidden dimensions. For typical configurations, this translates to meaningful savings in memory, training time, and inference speed.

In[11]:
Code
def count_parameters(input_size, hidden_size, architecture):
    """Count parameters for LSTM or GRU."""
    d, h = input_size, hidden_size

    if architecture == "lstm":
        # 4 gates: forget, input, cell, output
        return 4 * ((d + h) * h + h)
    else:  # gru
        # 3 gates: reset, update, candidate
        return 3 * ((d + h) * h + h)


# Compare parameter counts for common configurations
configs = [
    (128, 256),  # Small model
    (256, 512),  # Medium model
    (512, 1024),  # Large model
]

print("Configuration     | LSTM Params | GRU Params | GRU/LSTM Ratio")
print("-" * 65)
for input_size, hidden_size in configs:
    lstm_params = count_parameters(input_size, hidden_size, "lstm")
    gru_params = count_parameters(input_size, hidden_size, "gru")
    ratio = gru_params / lstm_params
    print(
        f"d={input_size:3}, h={hidden_size:4} | {lstm_params:>11,} | {gru_params:>10,} | {ratio:.2%}"
    )
Out[12]:
Console
Configuration     | LSTM Params | GRU Params | GRU/LSTM Ratio
-----------------------------------------------------------------
d=128, h= 256 |     394,240 |    295,680 | 75.00%
d=256, h= 512 |   1,574,912 |  1,181,184 | 75.00%
d=512, h=1024 |   6,295,552 |  4,721,664 | 75.00%

The ratio remains exactly 75% regardless of the input or hidden dimensions, confirming our mathematical derivation. As models scale up, the absolute parameter savings become substantial: for a large model with hidden size 1024, the GRU saves over 3 million parameters compared to an equivalent LSTM. These savings translate directly to reduced memory usage during training and inference, faster gradient computations, and potentially better generalization on smaller datasets.

The 25% parameter reduction has several practical implications. Training is faster because there are fewer gradients to compute and fewer weights to update. Memory usage is lower, allowing larger batch sizes or longer sequences. And with fewer parameters, GRUs may be less prone to overfitting on smaller datasets.

The following table shows parameter counts for various hidden sizes with a fixed input size of 256:

Parameter count comparison between LSTM and GRU architectures. The GRU consistently uses exactly 75% of the LSTM's parameters regardless of hidden size, with absolute savings growing substantially as models scale.
Hidden SizeLSTM ParametersGRU ParametersGRU/LSTM Ratio
128394,752296,06475%
2561,050,624787,96875%
5123,149,8242,362,36875%
7686,300,6724,725,50475%
102410,489,8567,867,39275%