Change and uncertainty / 6 of 7

Optimization and objectives

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Optimization and objectives” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Optimization searches for parameters that improve an objective. The objective must reflect the real task: minimizing average error may ignore a rare but costly failure. Constraints such as memory, latency, and fairness affect which solution is useful.

Use small numbers first and work one operation at a time. Track the shape and units of every quantity before doing algebra. The equations here describe idealized objects; implementing them on a computer introduces finite precision and resource constraints. You can understand the mechanism before learning every proof.

Under the hood

Gradient descent updates parameters in the negative gradient direction. A learning rate that is too small is slow; one that is too large can oscillate or diverge. Nonconvex objectives may have multiple stationary points.

wt+1=wt−η∇L(wt)w_{t+1}=w_t-\eta\nabla L(w_t)
wₜ is the current weight, η (eta) is the learning rate, and ∇L is the gradient. At w = 0 the gradient is −6, so a rate of 0.1 gives 0 − 0.1 × (−6) = 0.6.
A useful caution

Lower training loss does not guarantee better test performance.

A worked example

For L(w)=(w−3)², the gradient is 2(w−3). At w=0 and rate 0.1, the next value is 0.6.

How to use this way of thinking

Check a symbolic result with a numeric example, then consider an edge case such as zero, a very large value, or an incompatible shape. Explain what each symbol means rather than memorizing the equation. If a result surprises you, inspect the assumptions and the units first.

See the mechanism

Educational simulationRuns in your browser with simplified rules and example settings.
Try this

Start at −3. Take a step at 0.5, then take several steps at 1.1. Compare the loss in the two runs and use the step history to explain the difference.

Opening the experiment…

Try it yourself

Use the experiment to compare rates 0.1 and 1.1 for the quadratic. Explain the trajectories.

Key takeaways

  • Divergence or oscillation
  • Lower training loss does not guarantee better test performance.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1What can an excessive learning rate cause?
2True or false: A sufficiently large learning rate can make gradient descent diverge.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Mathematics for Machine Learning (open textbook) (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close