🌏 中文版
This is part 3 of the Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques series. It follows Is Learning Feasible? Hoeffding and Learning Beyond the Data. It covers Lecture 5, Training versus Testing, and Lecture 6, Theory of Generalization, from Machine Learning Foundations. Together they open the course's second big question: "Why Can Machines Learn?"
The lectures are taught in Mandarin. The slides are in English.
Official materials used:
- MOOC slides 05_handout.pdf (L5) and 06_handout.pdf (L6), plus the Fall 2026 05e_handout.pdf (3 pages of extended slides for L5).
- Videos 18–25 of the Foundations YouTube playlist, listed below.
- Textbook Learning from Data (LFD): 2.0 and 2.1.1 for L5, 2.1.2 for L6, per the Fall 2024 course page.
- Practice: Fall 2024 HW2.
Access level: videos and slides alone are A2. Add the Fall 2024 homework PDFs and this stretch reaches A3, but there are no official solutions and Gradescope grading is for enrolled students only. The grading scale is defined in the global AI/CS course map.
L6 is optional, so here is how this post handles it
Both semesters mark L6 as not required. The Fall 2026 course page lists the four L6 videos under W4 (09/30) as "suggested watching (anytime)", while the L5 videos are "required watching (before class)". The Fall 2024 page files L6 under "optional" and offers two versions side by side: Yaser Abu-Mostafa's English Lecture 6 at Caltech, and Lin's four-part Mandarin version.
So the main text covers the L5 concepts plus the result of L6: a break point squeezes the growth function down to a polynomial. Every proof step lives in a collapsible block. Readers who skip them will not miss anything later posts rely on.
The problem: M is infinite
L4 concluded that with a finite hypothesis set (|H| = M) and enough data N,
P[|Ein(g) − Eout(g)| > ε] ≤ 2 · M · exp(−2ε²N)
L5 opens by splitting learning into two questions (slide 3):
- Is Eout(g) close enough to Ein(g)?
- Can we make Ein(g) small enough?
M pulls these in opposite directions. A small M guarantees the first but leaves too few choices for the second. A large M does the reverse. And the perceptron from L2 has infinitely many lines, so M = ∞ and the inequality says nothing.
Slides 7–8 trace where M comes from. To let the algorithm pick any hypothesis, we bound the chance that any hypothesis hits a BAD event. That uses the union bound, which assumes the BAD events never overlap and simply adds their probabilities. But two nearby lines h₁ ≈ h₂ have the same Ein on most data sets, so their BAD events overlap heavily. The union bound counts that overlap again and again, infinitely many times.
The L5 idea: similar hypotheses fail together, so group them by kind and count kinds.
From counting lines to counting dichotomies
How many lines, as seen from one point?
The plane holds infinitely many lines. Seen from a single input x₁, though, there are only two kinds: lines that label x₁ as ○ and lines that label it ×. Two points give 4 kinds. Three points in general position give 8, and three collinear points give only 6. Four points? Slide 13: however you place them, at most 14, which is less than 2⁴ = 16.
The two missing patterns are the XOR shape: one diagonal gets the same label, the other diagonal gets the opposite one. No single line can do that.
This "maximum number of kinds" is the effective number of lines. If it can stand in for M, and it is much smaller than 2N, then infinitely many lines are still learnable.
Dichotomies and the growth function
Slides 16–17 generalize the idea:
- Dichotomy: look at hypothesis h only through its outputs on x₁…xN, giving a ○× vector (h(x₁), …, h(xN)). All the dichotomies H can produce on those N points are written H(x₁, …, xN), and there are at most 2N of them.
- Growth function mH(N): the dichotomy count depends on where the inputs sit, so take the maximum over all possible sets of N inputs to remove that dependence.
Four examples
Slides 18–23 work out four hypothesis sets. They come back all the way through L7.
| Hypothesis set | Shape | mH(N) | break point |
|---|---|---|---|
| positive rays | 1D, h(x) = sign(x − a) | N + 1 | 2 |
| positive intervals | 1D, +1 inside an interval | ½N² + ½N + 1 | 3 |
| convex sets | 2D, +1 inside a convex region | 2N | none |
| 2D perceptrons | lines in the plane | < 2N for some N | 4 |
The convex-sets argument is worth remembering. Put N points on a big circle. Any ○× pattern can then be realized by a convex region traced slightly outside the ○ points. When some set of N points admits all 2N patterns like this, H shatters those points.
The 05e extended slides add two more examples. For 1D positive-and-negative rays (the decision stump), mH(N) = 2N: positive rays give N + 1 patterns, negative rays give another N + 1 by symmetry, and the all-○ and all-× patterns are counted twice, so subtract 2. Origin-passing 2D perceptrons also give 2N. The trick is to normalize the points onto a unit half-circle, then sweep the angle, which reduces the problem to decision stumps.
Try this: draw 4 points on paper and find, by hand, the two patterns a line cannot produce. It is the most concrete picture in the whole VC story.
Break point: where the growth function stops growing exponentially
Slide 24 defines it: if no set of k inputs can be shattered by H, then k is a break point of H, meaning mH(k) < 2k. If k is a break point, so are k + 1, k + 2, and so on. The course only discusses the smallest.
Watch the quantifiers. For 2D perceptrons, some set of 3 points can be shattered (three points in general position). For 4 points, no arrangement can be. So the break point is 4.
Slide 25 draws a conjecture from the table:
- No break point: mH(N) = 2N. That part is certain.
- Break point k: mH(N) = O(Nk−1).
Positive rays (k = 2) are O(N) and positive intervals (k = 3) are O(N²), so both fit. If the conjecture holds, plugging mH(N) into Hoeffding in place of M works: the polynomial eventually loses to exp(−2ε²N). L6 proves exactly this.
L6: how a break point caps the growth function
L6 has four videos: Restriction of Break Point, Bounding Function: Basic Cases, Bounding Function: Inductive Cases, and A Pictorial Proof. The result fits in two sentences:
- Define the bounding function B(N, k): the largest mH(N) can possibly be, given break point k. It is a purely combinatorial quantity that ignores what H looks like. Positive intervals and 1D perceptrons both have break point 3, for example, so B(N, 3) bounds both.
- One can prove B(N, k) ≤ Σi=0k−1 C(N, i), whose highest-order term is Nk−1. So whenever a break point exists, mH(N) is polynomial in N.
Putting mH back into the BAD-event probability gives the Vapnik–Chervonenkis (VC) bound (slide 25):
P[∃h ∈ H such that |Ein(h) − Eout(h)| > ε] ≤ 4 · mH(2N) · exp(−ε²N / 8)
Compared with 2 · M · exp(−2ε²N), M becomes mH(2N) and the constants get worse. For 2D perceptrons, the break point is 4 and mH(N) is O(N³), so learning with 2D perceptrons is feasible. This is the moment the PLA from L2 gets its theoretical footing.
Proof 1: the B(N, k) table and recurrence (slides 6–19)
Boundary cases (slides 8–10):
- B(N, 1) = 1. The set cannot shatter even one point, so every column holds a single symbol. Once the first dichotomy is in, no other fits.
- B(N, k) = 2N when N < k. There are not yet enough points to hit the break point, so every pattern is allowed.
- B(N, k) = 2N − 1 when N = k. Removing any one pattern is enough to avoid shattering k points.
Inductive case (slides 12–17), using B(4, 3). After checking all 22⁴ sets of dichotomies, the maximum is 11. Group those 11 by their first three coordinates (x₁, x₂, x₃):
- α groups appear in pairs, identical on the first three points with x₄ = ○ in one and × in the other (2α dichotomies in total).
- β dichotomies appear only once.
So B(4, 3) = 2α + β. Two observations follow:
- α + β are dichotomies on (x₁, x₂, x₃), and they still cannot shatter any 3 points. So α + β ≤ B(3, 3).
- If the α part could shatter any 2 of the first three points, pairing with x₄ would shatter 3 points, a contradiction. So α ≤ B(3, 2).
In general this gives B(N, k) ≤ B(N − 1, k) + B(N − 1, k − 1), and induction yields B(N, k) ≤ Σi=0k−1 C(N, i). Slide 18 notes that the "≤" is actually "=", and leaves the proof to math lovers. The bonus problem Q13 of Fall 2024 HW3 asks for exactly that ≥ direction.
A quiz on slide 11 makes one more point: for 2D perceptrons mH(4) = 14, while B(4, 4) = 15. The bounding function can be loose.
Proof 2: the three-step pictorial proof of the VC bound (slides 21–25)
The goal is to turn "infinitely many Eout values" into "finitely many cases".
- Replace Eout with E′in. Draw a second, "ghost" data set D′ of size N and compute E′in on it. If h is BAD between Ein and Eout, it is probably also BAD between Ein and E′in. This step turns ε into ε/2 and adds a factor of 2 in front.
- Decompose H by kind. Now only the 2N points of D and D′ matter, and on them the hypotheses fall into at most mH(2N) kinds. Apply the union bound over those finitely many kinds.
- Hoeffding without replacement. Treat the 2N examples as a small bin. Draw N at random for Ein and use the rest for E′in. |Ein − E′in| > ε/2 is equivalent to |Ein − (Ein + E′in)/2| > ε/4, and for a fixed h the without-replacement version of Hoeffding applies.
Together the three steps give 4 · mH(2N) · exp(−ε²N / 8). The quiz on slide 26 plugs in positive rays with ε = 0.1 and N = 10,000 and gets a bound of about 0.298. Even with ten thousand examples, the bound on the BAD probability is not small. L7 returns to that looseness.
Video list
L5 (required before class in Fall 2026):
L6 (optional in both semesters):
- Restriction of Break Point
- Bounding Function: Basic Cases
- Bounding Function: Inductive Cases
- A Pictorial Proof
English counterpart: in Caltech's Learning from Data, Lecture 5 is also called Training versus Testing and Lecture 6 is Theory of Generalization. It uses the same textbook. The Fall 2024 NTU course page links Abu-Mostafa's Lecture 6 right next to Lin's Mandarin version.
Practice: Fall 2024 HW2
HW2 was released on 2024-09-23 and due 10/07. It is worth 200 points plus 20 bonus points and spans L4 to L7. The problems tied to this post:
- Q1: the growth function of 2D perceptrons restricted to slope 1 or −1, for N ≥ 4.
- Q3: the growth function of 2D perceptrons that must pass through the point (11, 26). The 05e page on reducing origin-passing perceptrons to decision stumps is a good warm-up.
- Q4: the tightest upper bound on the VC dimension of a finite set of 6211 fixed perceptrons. It uses the L7 definition, but the idea is "how many patterns can finitely many hypotheses produce?"
- Q10–12: decision stumps. Q10 asks you to prove that under the given noisy data distribution Eout(hs,θ) = u + v·|θ|. Q11 has you implement the 1D decision stump algorithm, run it 2000 times with N = 12 and 15% noise, and plot (Ein, Eout). Q12 repeats this with a randomly chosen hypothesis.
- Q13 (bonus): an upper bound on the VC dimension of multi-dimensional decision stumps.
Q2, Q6 and Q7 are the L4 multi-bin sampling problems, covered in the previous post. The Q13 bonus of Fall 2024 HW3 asks for the lower bound on B(N, k); see Proof 1 above.
Try this: Q11 and Q12 need no data set, since the code generates its own data. Put the two scatter plots side by side and compare the median Eout − Ein for "pick the lowest-Ein hypothesis" against "pick any hypothesis". That gap is exactly what this post is about. With no official solutions, you can check your simulation against the Eout formula you derive in Q10.
Per the course schedule, Fall 2026 hw2 comes out on 10/07. As of 2026-09-30 it is not yet public.
Next
The next post, VC Dimension, Noise and Error Measures, gives "the largest non-break point" its formal name, the VC dimension dVC. It proves that d-dimensional perceptrons have dVC = d + 1, then extends the theory to noisy data.
Further reading: the Stanford CS229 generalization chapter guide approaches the same question by a different route.
References
- Machine Learning Foundations / Techniques MOOC page (Hsuan-Tien Lin)
- L5 Training versus Testing slides
- L6 Theory of Generalization slides
- L5 extended slides (Fall 2026)
- Machine Learning Foundations YouTube playlist (lectures in Mandarin, slides in English)
- Machine Learning, Fall 2026 course page
- Machine Learning, Fall 2024 course page
- Fall 2024 Homework 2
- Fall 2024 Homework 3
- Caltech Learning from Data telecourse
- Caltech Lecture 6 (Yaser Abu-Mostafa)
- Learning from Data textbook
- MOOC slide errata
Loading...