An interactive, animated Streamlit app that teaches school students how neural networks learn β step by step. Designed for classroom use in rural India, with no prior machine learning knowledge required.
The app walks through 7 guided steps, animating a live neural network:
| Step | Concept |
|---|---|
| πΌοΈ Step 1 | Input β an image is broken into numbers |
| β‘οΈ Step 2 | Forward Pass β signals flow through the network |
| β‘ Step 3 | Activation β neurons decide whether to βfireβ |
| π Step 4 | Output β the network makes a prediction |
| β Step 5 | Loss β we measure how wrong it was |
| π Step 6 | Backpropagation β the error flows backwards |
| π§ Step 7 | Weight Update β the network adjusts and learns |
A loss curve builds up as students repeat the training steps, letting them literally watch the network get smarter.
Make sure you have these two files in the same folder:
neural_network_animation.py
requirements.txt
You need Python 3.9 or higher. Check your version:
python --version
Download Python from python.org if needed.
pip install -r requirements.txt
streamlit run neural_network_animation.py
Your browser will open automatically at http://localhost:8501.
| Β | Minimum |
|---|---|
| Python | 3.9+ |
| RAM | 512 MB |
| Internet | Only needed for Google Fonts (optional) |
| OS | Windows, macOS, or Linux |
Works on low-end laptops. No GPU required.
| Control | What it does |
|---|---|
| β Prev / Next βΆ | Step through the 7 phases manually |
| Choose an input image | Switch between Cat, Dog, Car inputs |
| Learning Rate slider | Controls how big each weight update is |
| Auto-play toggle | Automatically advances through steps |
| Speed slider | Sets seconds between auto-play steps |
| π Reset Network | Resets all weights and the loss curve |
π your-folder/
βββ neural_network_animation.py # Main app
βββ requirements.txt # Python dependencies
βββ README.md # This file
The network has this architecture:
Input (3) β Hidden 1 (4) β Hidden 2 (4) β Output (2)
All weights are initialised randomly and update in real time as students click through the backpropagation step.
streamlit: command not found
python -m streamlit run neural_network_animation.py
Port already in use
streamlit run neural_network_animation.py --server.port 8502
Fonts not loading (no internet) The app still works fully β it falls back to system fonts automatically.
Slow on old hardware Reduce the number of auto-play steps by using Manual mode (β βΆ buttons).
| Package | Purpose |
|---|---|
streamlit |
Web UI framework |
matplotlib |
Network diagrams and loss curve |
numpy |
Matrix math for forward pass & backprop |
Pillow |
Image handling (used by Streamlit internally) |
Free to use for educational purposes. Share freely with students and teachers. β€οΈ
βEvery expert was once a beginner.β