(English version first. 中文版在後面。)


English Version

Reading and Editing Neural Networks Through Their Weights

In November 2026, the blog post Sparks of Weight-Space Programming showed an LLM reading the weights of neural networks as if they were programs. In one experiment it named the game each small policy network had been trained on, from the weights alone. In another it fixed the "thinking loops" of the small model Qwen3.5-0.8B by changing only 64 columns in two layers (0.016% of the weights), with no training.

In this homework you follow the same route by hand, with methods from this course. You may use an LLM to help you write code or discuss ideas, but every conclusion must be backed by a figure or a number that you produced.

Submit both notebooks (.ipynb), with all cells run and all outputs visible. Each notebook is a guided investigation: run the provided steps, fill in the TODOs, and answer every 📌 question in a Markdown cell next to it.


Part A — Weight Detective

Open Part A in Colab (a CPU runtime is enough)

Seven policy networks, labelled A–G, all have the same architecture (500 → 32 → 32 → 5, tanh). The input is a 10×10 grid with 5 channels (agent, moving objects, reward targets, obstacles, previous frame); the output is 5 actions (no-op, up, down, left, right). Each network was trained to imitate an expert player of one game. The candidates include Breakout, Freeway and Pac-Man, but some networks may have played games that are not on this list, and not every network is necessarily a clean single-game player.

The notebook first walks through a fully worked example (a Pong network): drawing the first-layer weights back onto the grid, looking at individual hidden units, reading the output layer, and tracing an approximate linear path from input to action.

Rules

Questions: Q1–Q7 in the notebook. The main one (Q4) is a table: network → game (or a description of an unknown game) → at least two independent clues, each with the figure or number it comes from → how confident you are and why.


Part B — Fixing a Model's Thinking Loops by Editing Its Weights

Open Part B in Colab (T4 GPU runtime)