The brief
Toko Kita is a small Indonesian online shop that sells coffee, kitchen equipment, stationery, home goods and a few electronics. The warehouse wants to know each morning how many units of coffee will sell that day, and a colleague has started a neural network for it in PyTorch. Before the shop relies on it, the owner wants someone on the team who understands what the training code is actually doing, rather than someone who copies it and hopes.
That's you. PyTorch can't run in the browser, so this project does by hand, in NumPy, the same things nn.Module, the loss function and the optimizer do for you: the forward pass, the loss, the parameter updates, and the decisions around training, like when to stop and which weights to keep. Once you've written these yourself, a PyTorch training loop stops being a ritual. Every line maps onto something you've built.
How the tasks work
Each task is checked automatically, like the module questions. The tickets fix the random seeds, learning rates and the order of the steps, so your numbers can be compared exactly with the expected ones. Follow them closely: in training code, doing the same steps in a different order really does give a different model. There are hints if you get stuck, but try each task without opening the solution first.
The tasks
| # | Task | Main skills |
|---|---|---|
| 1 | Forward pass and loss | Matrix shapes, ReLU, a two-layer network, MSE, a baseline |
| 2 | Early stopping | A training loop, validation loss, patience, keeping the best weights |
| 3 | Fix the training script | Debugging: exploding loss, wrong gradients, leaking validation data |
The data
All three tasks use daily_demand.csv, already loaded as the DataFrame demand. It has one row per day of 2024 (366 rows):
date, temperature, weekend, promo, ad_spend, units
The features are temperature (°C), weekend and promo (0 or 1) and ad_spend (millions of rupiah), and the target is units, the units of coffee sold. The first 300 rows are the training set, and the rest (from row 300) is the validation set. Each starter already standardises the features using the training rows' mean and standard deviation, so every feature is on a similar scale.
When you're ready, open Task 1.