L11 | English F3 Student Learning Log
L11 | 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)
- Matrix multiplication pairs each row of the first matrix with each column of the second, multiplies and adds.
- Python loops are slow; handing the whole job to C code or the GPU is far faster.
- Broadcasting automatically stretches the smaller tensor to match before operating.
- Reading papers is easier with a Greek-letter and maths-symbol cheat sheet.
Where I got stuck, and how I got unstuck
| Where I got stuck | How I solved it |
|---|---|
| I kept mixing up the multiplication order | Finger trick: go across the left matrix, down the right matrix. |
| Broadcasting rules felt abstract | I printed (3,1) + (1,4) in Python and saw the 3×4 table. |
My answers to the exercises
Q1. Compute [[1,2],[3,4]] @ [[5,6],[7,8]].
Top-left 1×5 + 2×7 = 19; top-right 1×6 + 2×8 = 22; bottom-left 3×5 + 4×7 = 43; bottom-right 3×6 + 4×8 = 50. Answer [[19,22],[43,50]].
Q2. A (3,1) tensor plus a (1,4) tensor gives what shape, and why?
(3,4). The first tensor's single column is stretched to 4 columns and the second's single row to 3 rows, so both become 3×4 and are added cell by cell.
Q3. Why does replacing Python loops with broadcasting or GPU operations speed things up so much?
Each step of a Python loop goes through the interpreter, which is slow. Broadcasting and PyTorch hand the whole batch to optimised C code in one go, and a GPU can work on thousands of numbers at once.
My Zettelkasten card
Card|Removing one loop can make code a thousand times faster
The same matrix multiplication ran about five million times faster on the GPU than with three nested Python loops. The trick is switching from 'one at a time' to 'all at once' and letting optimised low-level code do the work.
At our sports day, teachers used to add up scores by hand from paper lists, which took all afternoon. Then the IT teacher put the scores in a spreadsheet and one formula filled the whole column. Same idea: not working harder, but calculating differently. I did notice vectorised code is harder to read than loops, so as a beginner I write the loop version first to get it right, then switch to broadcasting.
My next step: multiply two 200×200 matrices with Python loops and with NumPy, and time both.
🔗 Related notes to grow next: → Coding: 'Make it right, then make it fast' → Work habits: 'Batching beats one-by-one' → Maths: 'Matrices handle many numbers at once'
Back to lesson note:L11_矩陣乘法_202611041526