Skip to content
StackDecode
AI & ML Atlas
Deep LearningarchitectureInteractive simulation

Bidirectional RNN

Reads the sequence forwards and backwards so each step sees both past and future.

The idea

Two RNNs run over the same input, one left-to-right and one right-to-left. At each position their hidden states are joined, so the representation of a word reflects the words before and after it. That helps tasks where the whole sentence is known in advance.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

1.50.15-0.10.10.05-0.050.1
  • positive
  • negative
  • gate (taller = more open)

A bidirectional RNN reads the sequence forwards and also backwards, so each position sees both sides. The first input (1.5) is the thing worth remembering.

step:
0
1/10

One memory unit unrolled across seven time steps. Try a bigger first input and compare the cells.

Step by step

  1. 1Run a forward RNN over the sequence.
  2. 2Run a backward RNN over the reversed sequence.
  3. 3At each position concatenate the two hidden states.
  4. 4Use the joined state for the prediction.

Where it is used

Tagging, named entity recognition, speech recognition.

Watch out for

Cannot be used for live generation, because the future is not available.

Related