Train your network

← Back to specs
High school 7 Rooms AI Neural networks Upper secondary

Teaching objectives

How does an autonomous spaceship "see" its surroundings, and how does it learn to dodge danger without anyone hand-coding explicit rules? This upper-secondary lab tackles supervised learning from the opposite end of the "Neural Networks" lab: instead of designing weights by hand, the student designs an agent's perception and then trains it by playing. Across 7 short rooms, the arc runs from "what information does an agent need?" to watching a neural network navigate on its own, thanks to examples the student generated themselves.

What you'll learn

  • The problem of perception is posed: a ship that collects stars and dodges bombs needs to turn its surroundings into numbers.
  • Students design directional sensors: the space around the ship is split into angular sectors, each carrying a proximity value to the nearest object.
  • They discover the need to compress information: raw distance (up to ~672 possible values) is quantized down to a small scale (e.g. levels 0–5) using a compression function (logarithmic vs. linear).
  • They explore design trade-offs: more sensors and more levels give more precision, but also blow up the number of examples needed to train — students tune both parameters and watch the estimated training time change.
  • The cycle of supervised learning by imitation is understood: every action taken (by the student or by a heuristic) produces a pair (sensor inputs → chosen direction) that accumulates as a training example.
  • Periodic retraining is observed: every so many accumulated examples, the network adjusts its weights using all available data.
  • Students compare training by playing with training via an automatic teacher: a simple heuristic (seek stars, avoid bombs) can replace the student as the example generator, showing that what matters is not who teaches but the quality and quantity of the examples.

Key mathematical ideas

  • Perception as a vector: the ship's continuous surroundings are translated into a fixed vector of numbers (one per sensor), the network's input representation.
  • Quantization reduces a continuous range of values to a small number of discrete levels; the choice of compression function (linear vs. logarithmic) determines which distance range is best distinguished.
  • The size of the input space grows with the number of sensors and levels per sensor, which directly impacts how many examples are needed to cover it reasonably well.
  • Learning by imitation is a case of supervised learning: examples (input, desired output) are not computed analytically but collected from an agent (human or heuristic) that already solves the task reasonably well.
  • The quality of the training data — not just the network's architecture — determines the final behavior: a mediocre teacher trains a mediocre network, and vice versa.

Room-by-room contents

Room 1 · How does the ship see?

A static scene shows the ship, stars and bombs. Students think about how the ship could perceive its surroundings and pick between options: camera, distance sensors, GPS or human control. The correct answer — distance sensors — is confirmed with an explanation of why this representation is compact and well-suited to a neural network.

Student tasks

  • Look at the scene and think about what information the ship needs.
  • Select the perception method best suited to a neural network.

Room 2 · Directional sensors

Students drag the ship around an interactive canvas and watch in real time how the colored wedges (yellow for stars, red for bombs) change intensity depending on how close each object is within that angular sector. A multiple-choice question consolidates the concept.

Student tasks

  • Drag the ship and watch how the wedges change as you approach stars and bombs.
  • Answer what the intensity of each sensor wedge represents.

Room 3 · The distance scale

A chart with two curves (logarithmic vs. linear) and a distance slider let students compare how each function maps pixels to a 0–5 level. Students choose which function is best for the ship's sensors.

Student tasks

  • Move the slider and compare the levels produced by the linear and logarithmic scales.
  • Choose which compression function is better and explain why.

Room 4 · Design your sensors

A levels slider (2–640) and a sensor-count selector (4, 6, 8, 12) show in real time the possible combinations and the estimated minimum play time. The choice is saved and carried over to the game in room 6.

Student tasks

  • Explore how levels and sensor count affect training time.
  • Choose the final sensor count and confirm the choice.

Room 5 · How the network learns

An animated neural-network diagram (inputs → hidden layer → output) and four written steps explain the cycle: sensors → computation → player movement → training example → retraining every 100 examples.

Student tasks

  • Read the four steps of the learning cycle.
  • Identify what the network's input is and what its output is.

Room 6 · Train your network!

The full game with three phases: Train (the student plays and teaches the network), Observe (the mouse controls position and the ship shows where the network would go), Play (the network navigates autonomously). The sensor count comes from room 4.

Student tasks

  • Play in Train mode until you accumulate enough examples and collect stars.
  • Switch to Observe and check the network points toward the stars.
  • Turn on Play mode and watch whether the network navigates correctly.

Room 7 · The heuristic as teacher

In the previous room the student generated the examples by playing; here a simple heuristic (seek the nearest star, avoid bombs) replaces them, playing on its own, collecting data and training the network with no human involvement. The student presses Start and watches how the quality of the "teacher" — not who it is — determines the quality of the learning.

Student tasks

  • Press Start and watch the heuristic play and train the network on its own.
  • Compare the result with the manual training in room 6 and discuss what determines the quality of the trained network.

Rooms to project

The most striking ones to show and discuss in class.

Room 3 · The distance scale — The visual comparison between the logarithmic and linear curve is the lab's key "aha" moment. Ideal to project and discuss as a whole class.
Room 4 · Design your sensors — Moving the levels slider from 640 down to 5 and watching the time drop from "impossible" to "7 minutes" is very striking. Ask different students to try extreme combinations.
Room 6 · Train your network! — The moment the network navigates on its own after the students have trained it is the lab's climax. Project it in Play mode after training together as a class.