Concept

RNN Sequence Processing Complexity

In a recurrent neural network (RNN) processing a sequence of length nn, updating the dd-dimensional hidden state involves a multiplication with a dimesdd imes d weight matrix, leading to a computational cost of O(d2)\mathcal{O}(d^2) per step. Consequently, the total computational complexity for the entire recurrent layer is O(nd2)\mathcal{O}(nd^2). Because the hidden state must be updated iteratively one token at a time, there are O(n)\mathcal{O}(n) sequential operations that cannot be parallelized, and the maximum path length between any two tokens is similarly O(n)\mathcal{O}(n).

0

1

Updated 2026-05-14

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L