# multilayer-perceptron
A simple multilayer perceptron implementation in NumPy.
## Requirements
- Python >=3.10 (pinned to 3.14 via `.python-version`)
- [uv](https://docs.astral.sh/uv/)
## Getting started
```bash
# install dependencies (creates .venv, respects uv.lock)
uv sync --all-groups
# quick sanity check (no data files needed)
uv run python -c "from MultiLayerPerceptron.main import MultiLayerPerceptron; import numpy as np; mlp = MultiLayerPerceptron([2,4,1]); print(mlp.frontprop(np.array([0,1])) )"
# download MNIST and prepare files (one-time, ~60k train / 10k test)
uv run mlp-download
# creates data/train.npy, data/test.npy, mnist.npy (initial weights for [784,32,16,10])
# run the MNIST demo (requires data/train.npy, data/test.npy, mnist.npy)
uv run python -m MultiLayerPerceptron.main
```
Manual data tooling (MNIST `idx` → `npy` via `idx2numpy`):
```bash
uv run python -m MultiLayerPerceptron.download --help
uv run python -m MultiLayerPerceptron.data # legacy, expects idx files in cwd
```
Development:
```bash
uv run ruff check .
uv run ruff format .
uv run ty check
uv run pytest
```
## How to use
1. Download data and save them in `.npy` format. See `MultiLayerPerceptron/data.py` for details.
2. Write a run file for processing data. See script in `MultiLayerPerceptron/main.py` for details.
## TODO
- [ ] Print stages
- [ ] Learning samples method
- [ ] Save mlp
- [ ] Choose error
- [ ] Choose function
- [ ] CLI
- [ ] Multithread / Multiprocess
