A 2D Long Short-Term Memory (LSTM) Recurrent Neural Network framework implemented from first principles in NumPy, without relying on PyTorch or TensorFlow for model operations or automatic differentiation.
This project was originally created upon finishing high school as an early programming project to learn Python and understand recurrent neural network mathematics and Backpropagation Through Time (BPTT). The original unedited state is tagged as v0.1.0-legacy (commit 771d128) and preserved in legacy/original_lstm.py. The repository contains both that legacy script and a modernized refactor with modular layer abstractions, type annotations, unit tests, and fused matrix gate acceleration.
Comparing ground truth signals with LSTM sequence predictions:
Achieves MSE loss < 0.01 on sequence prediction.
This project uses uv for dependency management.
- Install dependencies:
uv sync- Run the train script:
uv run train.py