AI_for_school_students

🧠 Neural Network Explorer

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.


πŸ“Έ What It Shows

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.


πŸš€ Getting Started

1. Clone or download the files

Make sure you have these two files in the same folder:

neural_network_animation.py
requirements.txt

2. Install Python

You need Python 3.9 or higher. Check your version:

python --version

Download Python from python.org if needed.

3. Install dependencies

pip install -r requirements.txt

4. Run the app

streamlit run neural_network_animation.py

Your browser will open automatically at http://localhost:8501.


πŸ–₯️ System Requirements

Β  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.


πŸŽ“ How to Use in the Classroom

Projector Demo (Teacher-led)

  1. Run the app on the teacher’s laptop, project it on screen
  2. Enable Auto-play from the bottom of the page
  3. Set speed to 2–3 seconds per step so students can follow
  4. After all 7 steps, click Next again to repeat β€” the loss curve will grow

Student Exploration

  1. Each student (or pair) runs the app on their own device
  2. Ask them to try all three input images: Cat 🐱, Dog 🐢, Car πŸš—
  3. Have them click through all 7 steps and watch how predictions change
  4. Challenge: β€œWhat happens to the loss when you click through many times?”

Discussion Questions


πŸŽ›οΈ Controls

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

πŸ—‚οΈ File Structure

πŸ“ your-folder/
β”œβ”€β”€ neural_network_animation.py   # Main app
β”œβ”€β”€ requirements.txt              # Python dependencies
└── README.md                     # This file

πŸ”¬ What’s Under the Hood

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.


πŸ› οΈ Troubleshooting

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).


πŸ“¦ Dependencies

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)

πŸ“„ Licence

Free to use for educational purposes. Share freely with students and teachers. ❀️


β€œEvery expert was once a beginner.”