An interactive web app for teaching how neural networks work.
Designed to walk a beginner through:
- Building a network (pick hidden layers, neurons, activation, optimizer, learning rate).
- Training it on real handwritten digits (MNIST) with a live loss/accuracy chart.
- Predicting — draw your own digit and watch each layer light up.
# 1. Create a virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate
# 2. Install dependencies
pip install -r requirements.txt
# 3. Launch the app
streamlit run app.pyA browser tab opens at http://localhost:8501.
- Open the How it works tab and read the 1-paragraph intro together.
- Go to Build:
- Start tiny: 1 hidden layer, 8 neurons. Click ✨ Create.
- On Train, run 3 epochs. Note the accuracy (~85-90%).
- Go back to Build and make it bigger: 2 hidden layers, 64 + 32 neurons.
- Re-train. Accuracy jumps to ~97%. → "More neurons = more patterns it can learn."
- On Predict, draw a
3, then a7, then something messy. Look at the activation diagram — point out which output neuron is brightest. - Try changing the learning rate to
0.1and re-train. It explodes / gets worse → "Too big a step makes it fall off the mountain."
| File | What it does |
|---|---|
app.py |
Streamlit UI with 4 tabs |
nn_core.py |
Keras model factory, training loop, activation extractor |
visualize.py |
Matplotlib network diagram, training curves, prediction bars |
requirements.txt |
Python dependencies |
- Python 3.10+
- macOS / Linux / Windows (TensorFlow installs the right wheel for your platform; Apple Silicon works fine)