Skip to content

Do These 4 Problems First — They Tell You What to Patch | Harvard CS181 Assignment 0

Aug 27, 20261 min
TL;DRHW0 checks CS181 prerequisites in four problems — y=Xw solvability, optimizing an objective, reasoning about randomness, and OLS in Python. The problem that slows you down most is the gap to patch before HW1.

🌏 中文版

Video status: Checked: no corresponding recording link listed on the public official page. Source details

⚠️ Edition: This guide tracks CS1810 Spring 2026 HW0 (hw0.tex, due 2026-02-02) with Spring 2025 HW0 as fallback. Prerequisites and grading are from the CS181 2026 site and CS181 2025 site.

TL;DR

HW0 is graded for completeness (4%, 2026 syllabus), but it is the only dedicated prerequisite screen. Four problems map to the textbook prerequisites — linear algebra, calculus, probability, and Python — and the slowest problem predicts what to patch before HW1's ice-core regression.

Why HW0 deserves its own post

The CS1810 Spring 2026 syllabus sets due February 2 and warns During the term, the staff will be prioritizing support for new material... it might be prudent to postpone. In other words, HW0 lets you decide in shopping week whether to delay a semester, not after HW1.

In the Harvard AI/ML Course Map taxonomy, CS181 is A3 (hw0-6 all in s26 homeworks, all learning will be in-person with no public recording links listed for the corresponding lectures). The closed loop starts at data/hw0.ipynb + hw0.tex. The 2025 edition (s25 homeworks) is the same for HW0, plus a practical.

How to submit (don't lose points on format)

Every assignment has two Gradescope entries — one for the writeup PDF (assign pages per question) and one for LaTeX + code (.py/.ipynb/.tex), the latter only checked for honor-code cases (CS181 homework page). For self-study, git clone https://github.com/harvard-ml-courses/cs181-s26-homeworks.git && git pull is the official workflow (s26 README).

What the four problems test (2026 main, 2025对照)

Given D={(x1,y1),(x2,y2)}, line y=w0+w1 x.

  1. Solve w0,w1 by substitution
  2. Rewrite as y=Xw with y,w∈R^2, X∈R^{2×2} and describe X,y,w
  3. Unique solution iff X invertible (det≠0) ↔ x1≠x2, then w=X^{-1}y
  4. Compare matrix vs substitution and state the matrix advantage
  5. For N>2, X∈R^{N×2} is not square — w=X^{-1}y no longer applies (overdetermined, needs least squares)
  6. Pick x1≠x2 and compute w in Python from X,y

Guide: Two points make the matrix form look like notation; a million points make it matter (batched ops, geometry, OLS). If Q3 is slow, patch with MML Book Part I §2-3 before HW1.

Problem 2: Optimizing Objectives — Calculus

The second problem in hw0.tex checks derivatives, first-order conditions, and what ∇f=0 means geometrically. This is the prerequisite for HW1's loss landscapes.

Problem 3: Reasoning about Randomness — Probability

The third problem returns to STAT 110 level: random variables, expectation, variance, Bayes. It is the foundation for later Bayesian Methods (2025 HW3) and Inference in Graphical Models (2025 HW6). See CS181 textbook / GenerativeModels and STAT 110.

Problem 4: Implementing Linear Regression — Code

Role-playing Steve the TF live demo, fit a line of best fit via OLS (not a perfect fit). data has two columns (x, y). You fix X's shape (one column of ones for the intercept + one column x) and explain why y.shape has no second dimension (y is 1D, X is 2D). This is the first theory + code pairing; HW1 reuses the same X,y on 800k years of ice-core temperatures (earth_temperature_sampled_train/test.csv, Jouzel et al. 2007).

A 90-minute check you can do tonight

  1. Clone s26 and open hw0/hw0.ipynb; get X.shape / y.shape to print
  2. Write the X invertible ↔ x1≠x2 condition by hand, then verify with random points
  3. Score each problem (smooth / slow but solved / needed lookup / blocked) — the slowest is your week-1 patch (linear algebra → MML Book, probability → STAT 110, code → CS50x Python)

Where it leads

After HW0, HW1 Regression (ice-core), HW2 Classification, HW3 Kernels & Neural Networks, HW4 Transformer, HW5 Clustering/PCA, and HW6 Sequential Models are new material rather than remediation. The 2025 practical (Kaggle-style) is the capstone if you want more after HW6; 2026 has no practical, so use the 2025 version.

Solve two invented points algebraically and as a matrix

This is an invented teaching example, not a lecturer experiment or official assignment solution.

Using invented values rather than assignment numbers, points are (0,1) and (2,5). From y=w₀+w₁x, the first yields w₀=1; the second gives 5=1+2w₁, so w₁=2. Matrix form is X=[[1,0],[1,2]],w=[1,2],y=[1,5]; multiplication reproduces y. X is 2×2 and both vectors have length two.

Check and answer: For (0,1) and (0,5), is there still a unique exact fit? No: identical inputs require different outputs, so no function line passes through both; X has identical rows and is singular. Check data and rank before choosing a solver.

Course video sources

Checked the official CS1810 Spring 2026 schedule and syllabus. This guide uses homework, section, or exam materials; the corresponding entries do not list a public lecture video. Slides and section materials are provided. No public listing does not mean that a recording never existed.

Official sources:

Checked on 2026-10-10.

Update Log

  • 2026-10-11: Added an invented worked example and comprehension check, preserving source limits and assignment scope.
  • 2026-10-10: Added explicit video status and checked recording sources and access notes.
  • 2026-10-10: Rechecked video status. Re-read the official schedule and syllabus; they still list no public lecture video for this topic.

References