🚨 2026 Home Tasks β€” the real ones

πŸ€– Robot Delivery Academy

Teach a robot to deliver packages by copying an expert β€” and learn why copying is harder than it looks.

Behavioral cloningPyTorchCNNImitation learningβ˜…β˜…β˜…β˜† conceptually subtle

πŸ“œThe task, in plain English

A delivery robot lives on an 8Γ—8 grid city. Each episode: start somewhere, drive to the depot holding a package, pickup, drive to the destination depot, dropoff. Walls block movement, and every map is a bit different. You must train a model that learns this behavior purely from expert demonstrations β€” supervised pairs of observation β†’ action. Writing a path-finding algorithm (A*, BFS, planning) is explicitly forbidden: they're testing whether a model can learn the behavior, not whether you can code a solver.

Input (one observation)grid: 6Γ—8Γ—8 tensor (channels: walls, depots, robot, package, destination, carrying-flag) Β· vector: 13 numeric features Β· action_mask: which of the 6 actions are legal right now
OutputOne action id 0–5: south / north / east / west / pickup / dropoff
Training datatrain_demos.pkl β€” successful expert trajectories (observation + action at each step)
MetricEpisode Success Rate: package delivered within 120 steps, replayed in the provided simulator
Submissionpredictions.zip β†’ predictions.jsonl, one line per test scenario: {"layout_id": ..., "episode_seed": ..., "actions": [1,1,2,4,0,5]}
The trap in the metric
You train per-step (predict the expert's next action) but you're scored per-episode. A model that's 95% right per step still makes ~1 error every 20 steps β€” and one early wrong turn puts the robot in states the expert never visited, where it has no idea what to do. Errors compound. This is the classic imitation-learning lesson: action accuracy β‰  episode success.

πŸ”§The baseline you're given

A complete, honest baseline is provided β€” and its own description lists its flaws:

  1. Dataset: flattens every observation β€” the 6Γ—8Γ—8 grid is reshaped into a 384-long vector and concatenated with the 13 features β†’ 397 numbers.
  2. Model: a two-hidden-layer MLP (397 β†’ 128 β†’ 128 β†’ 6), cross-entropy loss, Adam, 30 epochs.
  3. Inference: picks the argmax action; the action_mask is applied only at inference time, not during training.
  4. Evaluation: full-episode rollouts in the provided simulator, with GIF replays of episodes so you can literally watch it fail.

Stated limitations (= your to-do list, verbatim from the notebook): flattening destroys spatial structure; rare actions (pickup/dropoff occur ~2Γ— per episode vs dozens of moves) are under-learned; the mask isn't used in training; the architecture is deliberately small.

πŸš€Baseline vs. solution

⚠️ The baseline (what you are given)
  • Grid flattened to 384 numbers β€” the model can't "see" that a wall is next to the robot
  • MLP treats position 27 and position 28 as unrelated inputs
  • pickup/dropoff drowned out by thousands of move actions
  • Trains on all logits incl. illegal actions
  • Only per-action accuracy watched during training
βœ… The winning approach
  • Small CNN on the 6Γ—8Γ—8 grid (2–3 conv layers) so spatial patterns β€” "wall ahead", "depot two cells east" β€” are visible; concatenate the 13-dim vector after the conv features
  • Weight rare actions: class weights in the loss or oversample pickup/dropoff steps
  • Mask during training too: set illegal-action logits to βˆ’βˆž so the model never wastes capacity on them
  • Evaluate with episode success rate after every change, not accuracy β€” replay failures in the simulator and categorize them (lost before pickup? circling near walls? wrong dropoff?)
  • Light data augmentation if legal (e.g., exploiting grid symmetry) and longer training with early stopping on episode SR
Why the CNN matters most
Convolutions slide a small window across the grid, so "wall directly north of robot" produces the same feature wherever it happens on the map. The MLP has to re-learn that fact separately for all 64 positions. Same data, same labels β€” but the CNN generalizes to maps it never saw, which is exactly what the test measures.

πŸ§’Explain it like I'm brand new

Analogy: learning to drive by watching dashcam videos of a perfect driver. You learn "in this exact situation, she turned left." Two problems: (1) if you only ever memorize photo→action pairs, you never learn the concept of a road; (2) the moment you make one mistake she never made — you drift onto the shoulder — you're in a situation that appeared in zero videos, and you panic. That's behavioral cloning and its compounding-error problem in a nutshell.

  • Why a CNN? An image (or a grid) has local structure β€” nearby cells matter to each other. A CNN is a model that looks through a small sliding window, so it learns "wall next to me" once, instead of 64 times.
  • Why do rare actions need help? If 95% of your flashcards say "drive forward," you'll answer "drive forward" to everything and still score 95% β€” while failing every pickup. Weighting tells the loss: the rare cards count more.
  • What's an action mask? A list of which moves are legal right now. Using it during training is like removing impossible answers from a multiple-choice exam before studying.

πŸ’¬The Gemma 4 playthrough (2000-token limit)

Chat 1 Β· Understand the baseline (paste code, ask for reading help)
YOU
Beginner here. This is the Dataset + model from a baseline I must improve (behavioral cloning, 8x8 grid, 6 actions). Explain in 8 bullet points max what it does and its 3 biggest weaknesses:
<paste the ~40 lines of Dataset + MLP code>
GEMMA 4
β€’ Collects (observation, action) pairs from every expert trajectory step
β€’ Flattens the 6Γ—8Γ—8 grid + 13-dim vector into one 397-dim input
β€’ 2-layer MLP classifies the next action, cross-entropy loss
β€’ Action mask applied only at inference
Weaknesses:
1. Flattening discards spatial structure a CNN would exploit
2. pickup/dropoff are rare classes β€” will be under-predicted
3. Per-action accuracy is optimized but episode success is scored
Chat 2 Β· CNN in one piece
YOU
Write ONLY a PyTorch nn.Module: input a (B,6,8,8) grid tensor and a (B,13) vector. Two Conv2d layers (6β†’32β†’64, 3x3, padding=1, ReLU), flatten, concat the vector, then Linear(64*64+13 β†’ 128) β†’ ReLU β†’ Linear(128 β†’ 6). Code only, max 35 lines.
GEMMA 4
import torch, torch.nn as nn

class GridPolicy(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Sequential(
            nn.Conv2d(6, 32, 3, padding=1), nn.ReLU(),
            nn.Conv2d(32, 64, 3, padding=1), nn.ReLU(),
        )
        self.head = nn.Sequential(
            nn.Linear(64*8*8 + 13, 128), nn.ReLU(),
            nn.Linear(128, 6),
        )
    def forward(self, grid, vec):
        z = self.conv(grid).flatten(1)
        return self.head(torch.cat([z, vec], dim=1))
Verify: x = torch.randn(2,6,8,8); v = torch.randn(2,13); print(GridPolicy()(x,v).shape) β†’ torch.Size([2, 6]). ALWAYS this ritual before wiring it in.
Chat 3 Β· Rare-action weighting
YOU
My action labels are ints 0-5 in a list y_all. Actions 4 and 5 are rare. Give ONLY code to compute inverse-frequency class weights and use them in nn.CrossEntropyLoss. Max 10 lines.
Chat 4 Β· Mask in training
YOU
Each sample has action_mask, a (6,) 0/1 array of legal actions. Modify this line of my training step so illegal logits become -1e9 before the loss:
loss = criterion(model(grid, vec), y)
Give only the replacement lines.
GEMMA 4
logits = model(grid, vec)
logits = logits.masked_fill(mask == 0, -1e9)
loss = criterion(logits, y)
Chat 5 Β· Debugging a failed episode (the real skill)
YOU
My per-action accuracy is 0.96 but episode success rate is only 0.55. Replays show the robot reaches the package depot but oscillates north-south next to it without pressing pickup. 3 most likely causes + fastest fix for each, no code.
GEMMA 4
1. pickup under-predicted (rare class) β†’ increase its class weight / oversample pickup steps
2. Model can't tell 'on depot' vs 'next to depot' β†’ check the carrying/depot channels reach the conv input correctly
3. Deterministic argmax loops between two equal logits β†’ add the action mask at inference and break ties, or sample from softmax with low temperature

🎯Takeaways & what Day 1 might do with this

  • Pattern family: supervised classification wearing a robot costume β€” plus the imitation-learning lesson (distribution drift).
  • The notebook's stated limitations are the answer key. CNN, rare-action weighting, mask-in-training: all three are literally listed for you.
  • Diagnose by replaying episodes, not by staring at accuracy. The simulator + GIF tools are given to you for exactly this.
  • Format discipline: predictions.jsonl inside predictions.zip, exact field names. Submit the plain baseline's zip in the first 30 minutes.
  • Likely Day-1 extension: the notebook calls itself the "preparatory program for the Robot Training task" β€” expect bigger maps, partial observability, noisier demos, or multi-package episodes. The CNN + weighting + mask toolkit transfers directly.