🌏 中文版
Video status: Videos included. This article is written from the official MOOC handout 202_handout.pdf and transcripts of the four official videos, with formulas following the handout. The transcripts are machine transcripts made for this article (Whisper), not official captions, and no human has proofread them. The videos are taught in Mandarin; the slides are in English. Each section opens with its official video and the approximate time ranges. Page numbers refer to the number at the lower right of each slide (0/23 to 23/23), and wherever the text says "in the lecture" it is paraphrasing what is said in the video.
This is Techniques Lecture 2 in Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques. The Roadmap on page 1 of the handout divides Techniques into three ways of handling features, and this lecture belongs to the first, Embedding Numerous Features: Kernel Models. The conclusion of the previous lecture, Techniques Lecture 1: Linear SVM, takes up a single line on that page: linear SVM is more robust and solvable with quadratic programming (QP). This lecture deals with what the previous one left open: after a high-dimensional feature transform, that QP has too many variables to solve.
The prerequisites are the standard hard-margin SVM problem and the QP(Q, p, A, c) notation from the previous lecture, partial derivatives, and vector inner products. Foundations Lecture 14: Regularization used Lagrange multipliers once; remembering it makes things smoother, but you can follow along without it. After reading, you should be able to derive the dual problem from the primal one step by step on your own, write down the four KKT conditions, compute , , and by hand for a small data set, and say which points are support vectors.
The derivation in this lecture runs in a straight line. Here is the whole picture first:
- Primal SVM: the variables are and .
- Lagrange function: hide the constraints inside a max.
- Swap min and max: strong duality guarantees the answer does not change.
- Partial derivative with respect to : eliminate .
- Partial derivative with respect to : eliminate .
- Dual QP: the only variables left are .
- KKT conditions: recover and from .
Why solve a different problem: the primal SVM's variable count is tied to the feature dimension
(Video 00:00–01:09 reviews the previous lecture, 01:09–05:38 gives the motivation, 05:38–08:16 revisits Lagrange multipliers, 08:16–15:20 covers the Lagrange function, and Fun Time follows.)
Where the primal problem gets stuck
The previous lecture replaced with the transformed and got the non-linear hard-margin SVM (page 2 of the handout). Write the dimension of as :
This QP has variables ( plus the components of ) and constraints. The handout says the combination we want is "not many" boundaries, thanks to the large margin, and at the same time a sophisticated boundary, thanks to the feature transform. The trouble is that a sophisticated boundary needs a large , and the QP's variable count grows with it; the handout adds one more question: what if is infinite? In the lecture, Lin calls this a crazy idea: an optimization problem with infinitely many variables looks impossible to solve for now, and this lecture and the next are about finding the mechanism that makes it possible. So the goal of this lecture fits in one line: SVM without dependence on .
Page 3 lists the plan as a comparison:
| Original SVM | 'Equivalent' SVM | |
|---|---|---|
| Type | convex QP | convex QP |
| Variables | ||
| Constraints |
On the right, the numbers of variables and constraints depend only on the data size . In the lecture, Lin explains that whether you transform the data into a ten-thousand-dimensional space or a twenty-thousand-dimensional one, these two numbers stay the same. The problem on the right comes from a certain dual problem of the original one; in the lecture he describes the two problems as twins that correspond to each other.
The same page has a red warning box, "Warning: Heavy Math!!!!!!": the handout introduces only the necessary math, without rigor, and simply 'claims' results whose details are unnecessary, the way Foundations 'claimed' Hoeffding. In the lecture he adds that fairly deep optimization theory lies behind these results, and anyone who wants every step should turn to an optimization textbook. This article fills in the algebra the handout skips, but it does not prove strong duality either.
The tool: treating Lagrange multipliers as unknowns
Page 4 first looks back at Foundations Lecture 14. Regularization can be written in two equivalent ways: the constrained subject to , and the unconstrained . What connects them is the condition the optimal solution must satisfy, : every corresponds to some , and that is the Lagrange multiplier.
The two lectures use the multiplier in opposite ways. Regularization treats as a given parameter: in the lecture, Lin puts it this way: the user was supposed to give us , and we ask for directly instead, which makes the problem easy to solve. Dual SVM treats the multipliers as unknowns to solve for. The SVM has constraints, so there are multipliers, one per constraint.
The Lagrange function: constraints hidden in the max
Page 5 of the handout crosses out the multiplier symbol and writes instead. In the lecture, Lin explains that the SVM literature conventionally calls these multipliers , so he follows it. The Lagrange function is the objective plus each constraint multiplied by its own multiplier:
Rearranging the constraint gives , and the parenthesis holds exactly this quantity that "should be at most 0". The handout then claims:
In the lecture, Lin describes this two-level expression as a scoring process: for each that comes in, tune to make as large as possible, and that maximum is the score of this ; once every has been scored, pick the one with the lowest score. What the score is depends on whether this is a "bad" one or a "good" one:
- violates some constraint. The parenthesis of that constraint is positive. The larger you make the corresponding , the larger gets, so the max is .
- satisfies every constraint. Every parenthesis is at most 0, so after multiplying by every term is at most 0. The only way to maximize the sum is to make every term 0, and the max is .
So the function the outer min faces is wherever a constraint is violated and wherever all of them are satisfied. The min never picks , so the result is the same thing as the original "minimize over the feasible region". In the handout's words: constraints now hidden in max. Seen from the level of , there are no constraints left to watch; in the lecture, Lin says the original constraints tied our hands, and their absence is what later lets us take partial derivatives with respect to and directly.
An addition in this article: is necessary here. If negative were allowed, a feasible with even one negative parenthesis could push the max to through a negative times a negative, and the argument above would fail.
Fun Time: the Lagrange function of two points
Question (page 6): Consider two transformed examples and with and . What is the Lagrange function of hard-margin SVM?
Answer: 2. The handout only says "By definition"; here is the substitution. For the first example, and , so the parenthesis is . For the second, and , so the parenthesis is . The two minus signs keep the sign in front of negative and turn the sign in front of positive.
Each of the other choices corresponds to a different data set: choice 1 is both examples being , choice 4 is both being , and choice 3 swaps the two labels into and . These two points come back in the Fun Time of the third section.
Swapping min and max, then eliminating b and w
(Video 00:00–02:36 is weak duality, 02:36–05:35 strong duality, 05:35–09:48 eliminating , 09:48–14:20 eliminating , 14:20–17:45 the KKT conditions, and Fun Time follows. The YouTube title of this video spells Lagrange as Largange; the spelling on the handout is correct.)
Weak duality: swapping gives a lower bound
The problem is now . The outer variables are still , so is still there. Page 7 swaps the order of min and max in two steps.
Step one. Fix any with every . For any , the max picks the largest value over all , so it is certainly no smaller than the value at one particular choice:
The handout's note is max ≥ any. The left side is no smaller than the right side at every , so the minimum of the left side is also no smaller than the minimum of the right side (at the left side's minimizer the right side's value already does not exceed it, and the right side's minimum can only be smaller):
Step two. The inequality above holds for every , so it also holds for the one that makes the right side largest. The handout's note is best is one of any:
The right side is the Lagrange dual problem. The prime on is only notation and is dropped from here on. Setting the math aside, the one-sentence version from the lecture is that the dual problem is what you get by swapping the two actions min and max. Every gives the original problem a lower bound, and the dual problem looks for the highest of those lower bounds; solving the dual gives a lower limit on the primal's optimal value, not necessarily the optimal value itself. This '≥' is called weak duality, and it holds for any optimization problem. In the lecture, Lin calls the relation a weak one because all it tells you is which side is above and which is below.
Strong duality: when equality holds
A lower bound alone is not enough; we want the same answer. Page 8 claims: when equality holds it is called strong duality, and a QP has strong duality as long as three conditions are met, which the handout calls constraint qualification:
- convex primal.
- feasible primal. For the SVM, this means the data is linearly separable in the space after the transform.
- linear constraints.
The SVM satisfies all three, so there exists a that is optimal for both sides at once, which the handout calls a primal-dual optimal solution. In the lecture, Lin spends only one sentence on the third condition: the constraints of a QP are linear to begin with. So the first two are the ones that really need checking. The handout does not prove this step, and neither does this article.
What strong duality buys is permission to solve the problem on the right instead. Why is the right side better? In the lecture, Lin explains that the optimization over now sits in the inner level, is the first thing to be done, and has no constraints at all. Unconstrained optimization is something we handle better, just as in gradient descent the ball may roll in any direction.
Eliminating b: the partial derivative with respect to b
The inner level of the dual problem is with no constraints on , so the partial derivatives are 0 at the minimum (page 9); in the lecture, Lin explains that the optimal solution has to be at the bottom of the valley, where the gradient is 0. First separate out the part of that contains :
Take the partial derivative with respect to :
The handout says there is no loss of optimality if we solve with the constraint added. The reason given in the lecture: adding an arbitrary constraint might change the optimal solution, but this one will not, because the optimal solution has to satisfy it anyway. This article adds one more way to see it: is linear in , with coefficient . Whenever this coefficient is not 0, pushing to infinity in the right direction makes the inner min . The outer level is looking for a maximum and will not choose an that makes the inner level , so only with need to be considered.
With this constraint added, the coefficient of the term is 0 and the whole term vanishes. In the lecture, Lin is blunt about it: is always going to be multiplied by 0, so why keep writing it; cross it out.
The price is that can no longer be found in the dual problem. At this point in the lecture Lin asks on the students' behalf how we make predictions once is gone; the answer waits until has been solved, in the third section.
Eliminating w: the partial derivative with respect to w
Next take the partial derivative with respect to the -th component of (page 10). Differentiating gives ; differentiating gives :
Every component looks the same, so in vector form this is
The inner level is an upward-opening quadratic in , so the point where the partial derivatives are 0 is the minimum. Before substituting it back, tidy up the summation term:
The last equality just replaces the parenthesis with . The inner minimum is therefore
The coefficients of the two terms add up to . The slide colors the substituted purple, and in the lecture Lin explains this is a reminder that it is now a quantity computed from . The inner min is done, so the min can simply be dropped from the expression, and the remaining problem contains only :
The handout also lists under the max. It specifies how is determined by and places no restriction on itself, so it is dropped when the problem is written in standard form in the next section.
KKT conditions: four things an optimal solution must satisfy
Page 11 collects the conditions used along the way. KKT is an acronym of the surnames of three researchers in optimization. If is primal-dual optimal, then:
- Primal feasible: . These are the constraints of the primal problem.
- Dual feasible: . These are the constraints of the dual problem.
- Dual-inner optimal: , and . These are the results of the two partial derivatives just taken.
- Primal-inner optimal: , for every .
In the lecture, Lin says the first two go without saying: something that fails a side's own constraints cannot be called a solution of that side.
For the fourth, the handout writes only "at optimal all 'Lagrange terms' disappear". Going back to the argument in the first section makes it clear: a feasible makes every term at most 0, and for the inner max to reach , every term has to be exactly 0. When a product of two numbers is 0, at least one of them is 0: either , or the point makes exactly. Page 16 gives this condition a name, complementary slackness.
In the lecture, Lin gives it a memorable analogy: and the quantity in the parenthesis are like Harry Potter and Voldemort, and at least one of the two has to die (equal 0); both may die, but both cannot live. For the rest of the lecture he keeps calling this one the Harry Potter condition.
Together the four are the Karush-Kuhn-Tucker (KKT) conditions. The handout says they are necessary for optimality and, here, sufficient as well. Sufficient means that once you find a that satisfies all four, it is the optimal solution, with no need to compare it against other candidates. The numerical example below relies on this.
Fun Time: KKT for a one-variable problem
Question (page 12): For a single variable , consider minimizing subject to two linear constraints and . The Lagrange function is . Which of the following equations that contain are among the KKT conditions of the optimization problem?
- and
- and
- all of the above
Answer: 4. The handout's answer matches each of the three choices to one condition: choice 1 contains the dual-feasible constraints, choice 2 the dual-inner-optimal constraints, and choice 3 the primal-inner-optimal constraints, which is the Harry Potter condition from the lecture. Choice 2 comes from differentiating with respect to : .
An addition in this article: this problem can be solved outright as a check. Within , is better the smaller is, so . Since , choice 3 forces ; choice 2 then gives . Check everything: , , , , , and all of them hold. The constraint that actually pins down the optimal solution, , gets a positive multiplier, and the inactive gets a multiplier of 0. This is the same phenomenon as "only points on the boundary can have a positive " in the SVM.
Handing the dual to QP, then recovering w and b from α
(Video 00:00–02:23 writes the standard form, 02:23–07:22 maps it to the QP solver, 07:22–10:20 discusses special solvers, 10:20–13:45 recovers and from , and Fun Time follows.)
Writing it in standard form
Page 13 makes two purely cosmetic changes. First, expand the squared norm into a double sum:
Second, multiply the whole objective by so that the max becomes a min. In the lecture, Lin contrasts this in passing with the earlier time a max was turned into a min by taking a reciprocal, which only works when the quantity being optimized is positive; here a minus sign is added instead. The result is what the handout calls the standard hard-margin SVM dual:
The variables are the values , and the constraints are one equality plus the constraints , in total. What page 3 promised has been delivered. The that used to sit under the max is gone; the account given in the lecture is that it only describes the relation between and , and since we now want to concentrate on solving for , we set it aside for the moment.
The equality has an intuitive reading, also given in the lecture: move the terms with and those with to opposite sides, and it says that the sum of over the positive examples (the points drawn as circles on the slides) must equal the sum of over the negative examples (the points drawn as crosses).
Mapping to the QP solver's inputs
The QP solver from the previous lecture takes the format subject to . Page 14 matches the dual problem to it term by term, with the variable now being :
| QP input | What dual SVM fills in | Where it comes from |
|---|---|---|
| The entry of | coefficients of the double sum | |
| ( copies of ) | ||
| , | one half of the equality | |
| , | the other half of the equality | |
| = -th unit direction, | the lower bounds |
This format accepts only '≥', so the equality has to be split into two inequalities pointing in opposite directions. A note at the bottom of the page says many solvers treat equality and bound constraints specially for numerical stability. The advice in the lecture is that the split above is only a generic illustration; in real use, first read the documentation of the QP program you have, which most likely lets you specify equalities and bounds directly, and then just put the coefficients in the right places.
An addition in this article, on something the handout labels "(convex)" without explaining. For any , , so is positive semi-definite, the objective is convex, and what the QP solver finds is the global optimum.
In practice, use a special solver
Page 15 writes this matrix as (D for dual) and points out two difficulties:
- is often non-zero (the inner product is 0 only when the two vectors happen to be perpendicular), so is a dense matrix. In the lecture, Lin compares it with the previous lecture: the primal problem's contains an identity matrix, with values only on the diagonal and 0 everywhere else.
- The handout's number is that with , a dense takes more than 3G of memory. What Lin says in the lecture is that even if you use the symmetry and store only half, it still takes more than 3G. This article's check: entries, half of that is , and at 8 bytes per double-precision floating-point number the total is 3.6 GB.
So with a lot of data you need a solver written specifically for the SVM: one that does not store the whole (the approach mentioned in the lecture is to compute only the entries that are needed, when they are needed) and that properly exploits the special structure of the one equality and the lower bounds. The handout's conclusion is that it is usually better to use a special solver in practice. In the lecture, Lin puts it more strongly: hand this problem to a general-purpose program as an ordinary QP and it may take forever to solve.
Recovering w and b from α
After the solver returns the optimal , it still has to be converted back into before we can predict; in the lecture, Lin says is only an intermediate product. Page 16 uses the KKT conditions:
: use the third condition directly, .
: the third condition does not contain . The first condition (primal feasible) gives only a range: points with require , and points with require . An equality has to come from the fourth condition. As soon as we find one point with (Harry Potter lives, so Voldemort has to die), complementary slackness forces
Multiply both sides by ; since , this gives , that is,
A reminder from the lecture: mathematically, every point with yields the same ; with a real solver, numerical error makes different points yield slightly different values of .
is exactly what the previous lecture called being on the fat boundary. So complementary slackness also has a geometric reading, which the handout puts at the bottom of the page: a point with must be on the fat boundary, and it is a support vector (SV).
An addition in this article: is a point with guaranteed to exist? If every were 0, the third condition would give , and the first would become for every . When the data contains both positive and negative examples, and cannot both hold, so the optimal solution always has at least one positive .
A numerical example: solving the dual for four points
The calculation below was done for this article and is not on the slides. The data is the four points whose primal problem the previous lecture's handout solved by hand (page 17 of that handout). The figure on page 18 of this lecture's handout shows the same data, but the handout does not list the dual solution. No feature transform is used here, so .
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Step 1: compute . For example, . All of the entries:
The first row and first column are all 0 because is the origin, whose inner product with anything is 0.
Step 2: write out the dual problem. The constraints are and the four . Expanding the objective directly from produces six cross terms; it is cleaner to start from , because the quadratic term is just :
Step 3: use the equality to eliminate one variable. The equality gives . Substituting, the first component of becomes , and . The objective becomes
Step 4: minimize the two pieces separately.
- The first piece, : the derivative gives , so and the value is .
- The second piece: let , so and this piece equals . Since and it can only increase the value, . That leaves , whose derivative gives , so , that is, , and the value is .
Going back, , which does not violate . The dual solution is
Step 5: recover and .
The circles-and-crosses reading of the equality checks out too: for the negative examples and for the positive ones. Compute from any point with : point 1 gives ; point 2 gives ; point 3 gives . All three points give the same .
Step 6: check KKT.
| On the fat boundary? | ||||
|---|---|---|---|---|
| 1 | Yes | |||
| 2 | Yes | |||
| 3 | Yes | |||
| 4 | No |
All four conditions hold: the third column is at least 1 for every point, no is negative, , and the last column is all 0.
What this result means. The classifier is , the same as the answer that the previous lecture's handout got by solving the primal directly, and the margin is , the number marked on the figure on page 18. The support vectors are points 1, 2, and 3; point 4 is farther from the boundary and has , and if you remove it from the data, the result of every step above stays the same.
Strong duality is visible as well. Written as a max, the dual's optimal value is , and the primal's optimal value is ; the two are equal. Other feasible give only lower bounds that are worse:
| Feasible | Compared with the primal optimum 1 | |
|---|---|---|
| lower | ||
| lower | ||
| lower | ||
| equal |
In the third row, and ; you can work out the other rows the same way. Handing the same , , and constraints to a numerical QP solver (for example cvxopt in Python) also returns with objective value , in agreement with the hand calculation.
Fun Time: two symmetric points, what is b
Question (page 17): Take the two examples from the first section's Fun Time, and . After solving the dual problem of hard-margin SVM, assume that the optimal and are both strictly positive. What is the optimal ?
- not certain with the descriptions above
Answer: 2. Both are positive, so either point can be used to compute . The first point: . The second point: . Adding the two gives , so ; subtracting them gives . The reason given in the lecture is a single sentence: because of symmetry. The two points are symmetric about the origin, so the fattest separating line passes through the origin as well.
Choices 1 and 3 each satisfy only one of the two equations. Choice 4 is wrong because the two equations are already enough to determine , without knowing what is.
An addition in this article: even can be solved. The equality constraint gives , so . Substituting into gives . With as an example, , , , and is 1 for both points. The farther apart the two points are, the smaller is. As long as , both are always positive, so the assumption in the question holds automatically.
What the dual solution reveals: support vectors, and the feature dimension we haven't escaped
(Video 00:00–03:17 is support vectors, 03:17–05:43 the comparison with PLA, 05:43–07:31 the comparison of the two forms, 07:31–09:13 what remains unsolved, followed by Fun Time and the summary.)
The formal definition of support vectors
The previous lecture said that the points on the fat boundary determine the fattest hyperplane and the other points are not needed, and it called the points on the boundary support vector candidates. Page 18 now gives the formal definition: only examples with are called support vectors. On the slide, the word "(candidates)" is crossed out.
The relation between the two groups of points is
Complementary slackness guarantees only one direction: a point with must be on the boundary. Conversely, a point on the boundary can have equal to 0 (self-check question 2 has an example). In the lecture, Lin explains that there may be somewhat fewer support vectors than candidate points on the boundary, or just as many. The figure on page 18 shows the four points from above: the gray band is the fat boundary, the line in the middle is labeled , and the width is labeled 0.707; the three points , , and are drawn with boxes around them, and is not.
With this definition, both formulas for computing and involve only the support vectors:
Terms with contribute nothing to the sum, so the first equality can sum over the SVs only. The handout sums up this page as: SVM learns the fattest hyperplane by identifying support vectors with the dual optimal solution. In the lecture, Lin describes the same thing from another angle: the SVM works like a filter that sorts the data into two kinds, where the support vectors are useful and the other points do not help in finding the fat boundary and can be ignored.
w is a linear combination of the data: SVM and PLA side by side
Page 19 puts the SVM's next to PLA from Foundations Lecture 2: Perceptrons and PLA:
| How is written | Where the coefficients come from | |
|---|---|---|
| SVM | the solution of the dual problem | |
| PLA | the number of times example was used to correct a mistake |
PLA starts from and adds one every time it makes a mistake, so the final is naturally a sum of integer multiples of these vectors. The handout points out that in both cases is a linear combination of the , and calls 'represented' by data; the same is true of logistic regression and linear regression trained with gradient descent or stochastic gradient descent starting from , which is why Lin says in the lecture that the resemblance between SVM and PLA is not entirely a coincidence. What is special about the SVM is that it represents by the support vectors only.
In the lecture, Lin also brings out a layer of this comparison that is worth thinking about: the two algorithms disagree about which data matters. The SVM considers the points near the boundary important, PLA considers the points that are frequently misclassified important, and each represents with the points it considers important.
Comparing the two forms
Page 20 sets the two forms of hard-margin SVM side by side. The dual column is written with matrices: subject to and .
| Primal | Dual | |
|---|---|---|
| Variables | ||
| Constraints | , simple in form | |
| Suitable when | small | small |
| Physical meaning | locate specially-scaled | locate SVs and their |
Lin is more cautious in the lecture about the "suitable when small" cell: with too much data the dual is not easy to solve either, and the dual is used as a replacement only when the data is not large, or at least still solvable. Both eventually result in the same fattest hyperplane, and the classifier in both cases is .
Not done yet: d̃ hides in the Q matrix
The title of page 21 is Are We Done Yet?. The dual problem has variables and constraints, with no in sight on the surface. But to hand the problem to a solver, we first have to compute every entry of ,
is an inner product of two -dimensional vectors; computed by definition, multiplying component by component and adding up, it costs . The dependence on has moved from "the number of variables" to "the time to compute the matrix entries" and has not disappeared; in the lecture, Lin puts it as having gone into hiding where is computed, and if is infinite, this takes infinitely many steps and never finishes.
The handout's conclusion is that there is no dependence on only if we avoid this naïve computation, which is the business of the next lecture. The "Escaping Feature Dimension" in this article's title is only half done in this lecture: the number of variables has escaped, the computation of inner products has not.
Fun Time: how many points can be on the boundary
Question (page 22): Consider applying dual hard-margin SVM on examples and getting 1126 SVs. Which of the following can be the number of examples that are on the fat boundary, that is, SV candidates?
Answer: 3. SVs are always on the fat boundary, and there cannot be more points on the boundary than there are examples, so
Of the four choices, only 1234 falls in this range. 0 and 1024 are smaller than the number of support vectors, and 9999 is larger than the total number of examples.
The summary on page 23 condenses each of the four sections into a line: want to remove dependence on ; KKT conditions link primal/dual; another QP, better solved with special solver; SVs represent fattest hyperplane. The preview of the next lecture is computing inner product in efficiently.
Self-check
1. Two two-dimensional examples: with , and with . Compute the dual solution by hand, then recover and .
Answer: the equality constraint gives . Then , the objective is , and differentiating gives . So and . Point 1 gives and point 2 gives , which agree. For both points is 1, and both are support vectors.
2. Three examples: labeled , labeled , and labeled . The optimal solution is , . Which points are on the fat boundary? Which are support vectors?
Answer: for the three points is , , and , so all three are on the fat boundary and all are SV candidates. Now use : , where the second component requires , so and , and the equality constraint gives . Only the first two points are support vectors. is on the boundary yet is not a support vector, which is why the "⊆" cannot be written as "=".
3. Why does the constraint appear in the derivation? If some does not satisfy it, what is the inner ?
Criteria: the answer should say that is linear in with coefficient ; that when the coefficient is not 0, can make arbitrarily small, so the inner min is ; and that the outer max will not choose such an , so adding the constraint does not change the answer while making the term containing vanish.
4. In the four-point example, is feasible? What lower bound does it give for the primal problem?
Answer: and no component is negative, so it is feasible. , , , and the lower bound is . It is twice the optimal solution: the direction is right but it overshoots, and the lower bound of 0 it gives is worse than the optimal value 1.
5. There are examples and, after the feature transform, . How many variables do the primal and dual QPs each have? The dual is smaller, so where does it pay?
Answer: the primal has variables and the dual has . The cost is in preparing : it has entries, each needing one -dimensional inner product, about multiplications in total when computed by definition (symmetry saves half). There are fewer variables, but still shows up in the amount of computation.
Exercises and corresponding reading
The corresponding week in two semesters. The Fall 2024 course page puts linear SVM and dual SVM in the same week (W9, 10/28), and the slide code for this lecture is 202u. The Fall 2026 course page also puts them in W9 (11/04), with the two lectures taught together. The Fall 2026 slides for that week were not yet online as of 2026-09-30, so this article uses only the MOOC handout.
Textbook. Both course pages map this lecture to e-8.2 of Learning from Data (LFD). e-Chapter 8 is one of LFD's online chapters.
Homework. This lecture had no homework of its own in Fall 2024. The related problems are in Fall 2024 HW6 (released 2024-11-18, due 12-02), which has no official solutions:
- Q1: write PLA's as and ask how should be updated at each correction. This extends " represented by data" from page 19. You can write this version of PLA yourself and compare it with ordinary PLA on the same data to see whether agrees at every step.
- Q13 (bonus): derive the dual of the soft-margin SVM dual problem and compare it with the primal. Get fluent with this lecture's four steps (write the Lagrange function, swap, take partial derivatives, substitute back) before attempting it.
The guide to the whole assignment is in Techniques Homework and Final Project.
Further reading. Chapter 6 of the CS229 main notes derives the SVM dual in a different way and can be read alongside this lecture's version.
Next lecture. Techniques Lecture 3: Kernel SVM deals with the this lecture leaves behind: getting the inner product without computing the -dimensional features.
Course video sources
Original videos: Motivation of Dual SVM, Lagrange Dual SVM, Solving Dual SVM, Messages behind Dual SVM
Checked: 2026-10-13. The video IDs, titles, and lengths were taken from the official playlist on 2026-10-13; the videos have no caption track on YouTube, and what this article reports from the lecture comes from transcripts made for it.
Update Log
- 2026-10-13: Changed to one article per lecture. This article covers only Techniques Lecture 2 and was rewritten from the handout and the video transcripts.
References
- Techniques Lecture 2 handout, 202_handout.pdf: the main source for this article. The derivations in the four sections, the four Fun Time questions, and the figure on page 18 all come from this handout.
- Techniques Lecture 1 handout, 201_handout.pdf: the four points used in the numerical example and the primal solution come from its page 17.
- Machine Learning Techniques YouTube playlist: the IDs and titles of the four videos; what the text reports as said "in the lecture" is paraphrased from machine transcripts of these four videos.
- Hsuan-Tien Lin > MOOCs: the official entry for handouts and recordings.
- Machine Learning, Fall 2024 course page: the corresponding week and LFD chapter.
- Machine Learning, Fall 2026 course page: the corresponding week and LFD chapter.
- Fall 2024 Homework 6 (hw6_red.pdf): the content of Q1 and Q13.
- Learning from Data textbook website: the source of e-8.2.
- CS229 main notes, main_notes.pdf: further reading, the SVM dual derivation in Chapter 6.
- Reading NTU Hsuan-Tien Lin Machine Learning Foundations & Techniques: Course Overview: where this lecture sits in the whole course and the reading routes.
Loading...