# Deep Learning Math Lab

This companion lab supports the "Deep Learning Math Visualized" article series on haotianblog.

It uses only deterministic toy arrays. There are no external datasets, credentials, network calls, or large files.

## Setup

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

## Run All Demos

```bash
python src/run_all.py
```

The command writes reproducible CSV files under `results/` and SVG/PNG figures under `figures/`.

## Individual Demos

```bash
python src/gradient_check.py
python src/mlp_backprop.py
python src/optimizer_paths.py
python src/conv2d_im2col.py
python src/attention_math.py
```

## Files

- `src/gradient_check.py`: matrix calculus and finite-difference gradient check.
- `src/mlp_backprop.py`: two-layer MLP forward and backward pass.
- `src/optimizer_paths.py`: gradient descent, momentum, and Adam on a 2D quadratic.
- `src/conv2d_im2col.py`: 2D convolution, output shape, receptive field, and im2col.
- `src/attention_math.py`: scaled dot-product attention for three toy tokens.
- `results/*.csv`: deterministic numeric outputs used by the articles.
- `figures/*`: diagrams and visualizations used by the articles.

## Safety And Scope

The lab is educational. It is intentionally small so readers can inspect every number by hand and rerun the scripts locally.
