Concepts / SGD and subgradients of maximum functions

SGD and subgradients of maximum functions

Multiclass SVM handles several labels by scoring input-label pairs and selecting the largest score.

  • Programming

A Contest Among Labels

A multiclass SVM treats prediction as a competition among possible labels. For an input, it assigns a score to each input-label pair, then selects the label with the greatest score. The learned vector w and the class-sensitive feature mapping Ψ together produce these scores.

comparecomparecompareScore for label Ainput-label pairSelected labelgreatest scoreScore for label Binput-label pairScore for label Cinput-label pair
How are scores for the same input compared across possible labels, and how does the largest score identify the winner?

Prediction by Argmax

The prediction rule examines every candidate label in the label set. It evaluates the score associated with each pair consisting of the new input and one candidate label. The argmax operation returns the label whose score is greatest. Thus, the prediction is one selected label, not a collection of separate binary decisions.

Selecting the Highest-Scoring Label

Suppose a multiclass SVM assigns the same input the following illustrative scores: label A receives 2.1, label B receives 3.4, and label C receives 2.8. Which label does the prediction rule select?

Compare: The prediction rule compares the score for every candidate label on this input.

Find the maximum: Among 2.1, 3.4, and 2.8, the greatest score is 3.4.

Return the label: The label associated with the greatest score is label B.

The multiclass SVM selects label B.

candidategreatest scorecandidateInput, label Ascore 2.1Label BargmaxInput, label Bscore 3.4Input, label Cscore 2.8
How does the argmax operation map scores assigned to input-label pairs to the selected label?

The Generalized Hinge

For a training pair consisting of an input xᵢ and its correct label yᵢ, the generalized hinge examines alternative labels y′. Each alternative is evaluated using two ingredients: the loss Δ(y′, yᵢ), and the score difference between the alternative representation Ψ(xᵢ, y′) and the correct-label representation Ψ(xᵢ, yᵢ). The maximum over the alternatives identifies the most demanding alternative for that training example.

This maximum is central because training must respond to the alternative that places the greatest demand on the current model. The objective combines the average generalized hinge contribution over the training examples with a regularization term λ ‖w‖². The parameter λ is positive and controls the regularization term in the stated learning problem.

Finding the Most Demanding Alternative

For one training pair, suppose three alternative labels produce generalized-hinge quantities of 1.2, 2.7, and 1.9. Which alternative determines the maximum?

List the alternatives: The generalized hinge evaluates each alternative label for the training pair.

Compare their quantities: The illustrative values are 1.2, 2.7, and 1.9.

Locate the maximum: The value 2.7 is largest, so its associated alternative label is the maximizing label.

The alternative associated with 2.7 is the most demanding alternative for this training example.

Why SGD Looks for a Maximizer

The generalized hinge is not treated as an ordinary smooth expression because it contains a maximum function. In the SGD approach, the procedure first finds a label y in the label set Y that achieves the maximum in the generalized hinge definition. A subgradient result for maximum functions then supplies the basis for obtaining subgradient information.

evaluatetake maximumidentifysupplies basisTraining pairxᵢ, yᵢAlternative labelsy′ in YMaximum quantitylargest alternative valueMaximizing labelySubgradientinformationbased on the maximum
How does the class with the largest margin-violating score determine which subgradient is used?

From Maximizer to Weight Update

For one training example, SGD follows a compact sequence. It considers the correct label and the alternative labels, evaluates the generalized-hinge quantities, locates a label that achieves the maximum, and uses the resulting subgradient information in the learning step. The regularization term is part of the overall objective, so the learning problem balances regularization with average generalized hinge loss.

score withevaluateselect largestdetermineSGD learning stepCurrent weightswAlternative valuesgeneralized hingeMaximizing labelmaximum achievedSubgradientmaximum-based informationUpdated weightsnew wTraining examplexᵢ, yᵢ
How does SGD move from the current weights and a training example to an updated set of weights after locating the maximizing class?

When tracing this process, keep the order explicit: identify the training pair, evaluate the alternatives, find a maximizing label, obtain the corresponding subgradient information, and then perform the SGD learning step. The source material establishes this sequence but does not specify a numerical learning rate or a numerical weight-update equation.

Common Reasoning Errors

  • Choosing a label without comparing all candidate labels.

    The multiclass SVM prediction rule compares the score for every possible class and selects the greatest score.

    Fix: List the candidate-label scores and apply the argmax rule.

  • Treating the generalized hinge as if it had no maximum.

    The subgradient information depends on the label selected by the maximum-function step.

    Fix: First locate a maximizing label, then use the subgradient result for the maximum.

  • Confusing the prediction label with the training maximizer.

    Prediction compares candidate labels for a new input, whereas training examines alternatives for a labeled training pair.

    Fix: Identify whether the task is prediction or generalized-hinge evaluation before interpreting the maximum.

  • Ignoring regularization when describing the learning objective.

    The stated objective combines regularization with the average generalized hinge contribution.

    Fix: Mention both the regularization term λ ‖w‖² and the average generalized hinge loss.

Practice the Trace

MEDIUM

For a training pair, imagine that the generalized-hinge quantities for three alternative labels are 0.8, 1.6, and 1.1. Trace the SGD reasoning process without calculating a numerical weight update: identify the maximizing alternative, state what information it supplies, and distinguish this training step from prediction on a new input.

Hints
  • The largest of the three quantities identifies the maximizing alternative.
  • The maximizing label supplies the basis for the subgradient information.
  • Prediction instead compares scores for all candidate labels on a new input and returns the greatest-scoring label.

What do you think happens?

If the candidate-label scores for a new input are 4.0, 4.7, and 3.9, which label does the multiclass SVM select?

  • The label with score 4.0
  • The label with score 4.7
  • The label with score 3.9
Reveal answer

Answer: The label with score 4.7.

The prediction rule selects the candidate label with the greatest score.

Key Takeaways

  1. A multiclass SVM scores every input-label pair and predicts the label with the greatest score.
  2. The generalized hinge evaluates alternative labels for each training pair and uses a maximum to find the most demanding alternative.
  3. Because the generalized hinge contains a maximum, SGD first locates a maximizing label before using subgradient information.
  4. The learning objective balances the regularization term λ ‖w‖² with average generalized hinge loss.
  5. Prediction and training both involve maxima, but they apply those maxima in different contexts.

Key Takeaways

  • Multiclass SVM prediction is an argmax over scores assigned to all candidate labels.
  • The generalized hinge finds the alternative label that creates the greatest demand for a training example.
  • SGD uses the maximizing label because subgradient information for a maximum depends on that selection.
  • The overall objective combines regularization with average generalized hinge loss.
  • The training maximizer and the prediction winner should be distinguished by the context in which each maximum is taken.