L05 | English F3 Student Learning Log

Persona: I'm a Form 3 (Grade 9) student and I only read English. I know basic Python (variables, for loops, lists) and school algebra up to quadratics. I learn from the official pages, the videos with captions, and the book. Kaggle notebook steps are written as a practice log that follows the official notebooks.

What I understood (in my own words)

  • The Titanic data needs cleaning first: fill missing values, turn text categories into 0/1 columns, and shrink very large numbers.
  • A tensor is a table (or a table with more dimensions) that can live on the GPU.
  • Every round of the training loop is: guess, measure how wrong, get gradients, adjust the coefficients.
  • Sigmoid squashes predictions to between 0 and 1, which matches 'probability of surviving'.
  • Writing it all from scratch is fiddly, so real projects use fastai. But having done it once, I know what the library is doing for me.

Where I got stuck, and how I got unstuck

Where I got stuckHow I solved it
What's the difference between * and @?I tested it. * multiplies element by element; @ is matrix multiplication (multiply then add). (a * b).sum(axis=1) equals a @ b.
My loss went weird after a few epochsI forgot to zero the gradients after each update, so they kept adding up. coeffs.grad.zero_() fixed it.
What is e in the sigmoid formula?It's a constant, about 2.718. In code I just use torch.sigmoid.

My answers to the exercises

Q1. Compute sigmoid(−2), sigmoid(0), sigmoid(2) to three decimals. Why add sigmoid at the end when predicting survival?

sigmoid(−2) ≈ 0.119, sigmoid(0) = 0.5, sigmoid(2) ≈ 0.881. Survival is 0 or 1, so sigmoid keeps predictions in that range. The model doesn't have to work hard to land exactly on 0 or 1, which makes training much easier.

Q2. A tensor has shape (891, 12). What is its rank, and what do 891 and 12 represent?

Rank 2 (a 2-D table). 891 is the number of passengers (rows); 12 is the number of features per passenger (columns).

Q3. Age has many missing values. Why does the course fill them with the mode instead of deleting those passengers?

Deleting them throws away all their other useful columns and shrinks the training data. Filling with the mode is the simplest fix and usually works fine. The fact that a value was missing can also be useful information.

Q4. Compute log(1+0), log(1+9), log(1+99) (natural log, three decimals). Why add 1?

log(1) = 0, log(10) ≈ 2.303, log(100) ≈ 4.605. We add 1 because log(0) is undefined (minus infinity), so a passenger with a free ticket would break the calculation.

Q5. The course trains 5 models that differ only in their starting values and averages them. Why does this beat a single model?

Each model starts from a different place and makes slightly different mistakes. Averaging cancels out the unrelated mistakes and keeps what they agree on, so the result is more reliable.

My Zettelkasten card

Card|Building it from scratch once shows you what the library does for you

Libraries are fast, but if you only ever use the library, you don't know where to look when something breaks. In this lesson Jeremy avoided fastai on purpose and wrote a linear model, a neural net and a deep model line by line, then swapped back to one line of fastai. Comparing the two, I could see that one line hides missing-value filling, normalization, initialization and a learning-rate search.

It's like when I learned Scratch. Remixing the teacher's game template was fun, but when a sprite got stuck I had no idea how to fix it. Once I built a catching game from a blank project, I understood collision detection, and the template finally made sense. I don't think you need to rebuild everything, though. Time is limited, so writing the core pieces yourself (like the training loop) is enough.

My next step this week: rewrite train_model without looking at my notes and reach at least 0.78 accuracy on Titanic.

🔗 Related notes to grow next: → Learning: 'Opening the black box once makes you trust it more' → Coding: 'Wrap exploration into functions so future-you can read it' → Data: 'The simplest way to fill gaps is often good enough'


Back to lesson note:L05_從零打造模型_202611041526

Built with LogoFlowershow