# georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch architecture

> Architecture diagram of the GitHub repository georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch
- Repository: https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch

## Overview

This is an educational PyTorch library implementing recurrent cells and stacked or bidirectional sequence models from scratch. The principal workflow is that a caller supplies a batch of sequences to a model, the model iterates through time using the corresponding cell, and a linear head returns final-step predictions. The README also describes a training demo, but its source was not sampled, so it is not mapped here. The model excerpt is partial; edges are limited to relationships shown in the excerpt or documented in the README.

Main entry points: [`rnnmodels.py`](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py) (Bidirectional model), [`rnncells.py`](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py) (RNN cell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_models["Sequence models"]
  node_simple_rnn["Simple RNN<br/>[rnnmodels.py]"]
  node_stacked_lstm["Stacked LSTM<br/>[rnnmodels.py]"]
  node_stacked_gru["Stacked GRU<br/>[rnnmodels.py]"]
  node_bidirectional["Bidirectional model<br/>[rnnmodels.py]"]
  node_output_head["Linear output head<br/>[rnnmodels.py]"]
end

subgraph group_cells["Recurrent cells"]
  node_rnn_cell["RNN cell<br/>[rnncells.py]"]
  node_lstm_cell["LSTM cell<br/>[rnncells.py]"]
  node_gru_cell["GRU cell<br/>[rnncells.py]"]
end

node_caller(("Model caller"))

node_caller -->|"supplies sequence"| node_simple_rnn
node_caller -->|"supplies sequence"| node_stacked_lstm
node_caller -->|"supplies sequence"| node_stacked_gru
node_caller -->|"supplies sequence"| node_bidirectional
node_simple_rnn -->|"calls per step"| node_rnn_cell
node_stacked_lstm -->|"calls per step"| node_lstm_cell
node_stacked_gru -->|"calls per step"| node_gru_cell
node_bidirectional -->|"selects by mode"| node_rnn_cell
node_bidirectional -->|"selects by mode"| node_lstm_cell
node_bidirectional -->|"selects by mode"| node_gru_cell
node_simple_rnn -->|"projects output"| node_output_head
node_stacked_lstm -->|"projects output"| node_output_head
node_stacked_gru -->|"projects output"| node_output_head
node_bidirectional -->|"projects output"| node_output_head
node_simple_rnn -->|"returns prediction"| node_caller
node_stacked_lstm -->|"returns prediction"| node_caller
node_stacked_gru -->|"returns prediction"| node_caller
node_bidirectional -->|"returns prediction"| node_caller

click node_simple_rnn "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py"
click node_stacked_lstm "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py"
click node_stacked_gru "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py"
click node_bidirectional "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py"
click node_output_head "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py"
click node_rnn_cell "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py"
click node_lstm_cell "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py"
click node_gru_cell "https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_simple_rnn,node_stacked_lstm,node_stacked_gru,node_bidirectional,node_output_head toneBlue
class node_rnn_cell,node_lstm_cell,node_gru_cell toneAmber
class node_caller toneIndigo
```

## Components

### Sequence models

- [Simple RNN](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py): `rnnmodels.py`
- [Stacked LSTM](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py): `rnnmodels.py`
- [Stacked GRU](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py): `rnnmodels.py`
- [Bidirectional model](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py): `rnnmodels.py`
- [Linear output head](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnnmodels.py): `rnnmodels.py`

### Recurrent cells

- [RNN cell](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py): `rnncells.py`
- [LSTM cell](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py): `rnncells.py`
- [GRU cell](https://github.com/georgeyiasemis/recurrent-neural-networks-from-scratch-using-pytorch/blob/main/rnncells.py): `rnncells.py`

### Other components

- **Model caller**

## Connections

- Model caller → Simple RNN: supplies sequence (evidence: `README.md`)
- Model caller → Stacked LSTM: supplies sequence (evidence: `README.md`)
- Model caller → Stacked GRU: supplies sequence (evidence: `README.md`)
- Model caller → Bidirectional model: supplies sequence (evidence: `README.md`)
- Simple RNN → RNN cell: calls per step (evidence: `rnnmodels.py`)
- Stacked LSTM → LSTM cell: calls per step (evidence: `rnnmodels.py`)
- Stacked GRU → GRU cell: calls per step (evidence: `rnnmodels.py`)
- Bidirectional model → RNN cell: selects by mode (evidence: `rnnmodels.py`)
- Bidirectional model → LSTM cell: selects by mode (evidence: `rnnmodels.py`)
- Bidirectional model → GRU cell: selects by mode (evidence: `rnnmodels.py`)
- Simple RNN → Linear output head: projects output (evidence: `rnnmodels.py`)
- Stacked LSTM → Linear output head: projects output (evidence: `rnnmodels.py`)
- Stacked GRU → Linear output head: projects output (evidence: `rnnmodels.py`)
- Bidirectional model → Linear output head: projects output (evidence: `rnnmodels.py`)
- Simple RNN → Model caller: returns prediction (evidence: `README.md`)
- Stacked LSTM → Model caller: returns prediction (evidence: `README.md`)
- Stacked GRU → Model caller: returns prediction (evidence: `README.md`)
- Bidirectional model → Model caller: returns prediction (evidence: `README.md`)
