DeepLLM Quiz
Deep Learning

Stochastic gradient descent, epochs and mini-batches

10 questions on stochastic gradient descent, epochs, noisy gradients, mini-batch size, shuffling and why small batches often win. With explanations.

  • 10 questions
  • Stopwatch
  • Instant feedback

Shown publicly with your score. Don’t use your full real name.

Sample questions

Play now ↑

Answers stay hidden. Start the quiz to play them.

  1. Sample 1

    By accident, a team copies every row of its data set so that each example appears twice. What happens to the cost of one update?

    • Both methods cost twice as much per update
    • Batch gradient descent costs about twice as much per update, while SGD's update is unaffected
    • Both methods are unaffected, since the error is the same
  2. Sample 2

    A team raises its mini-batch size from 32 to 3,200, which is 100 times larger. Roughly how much less noisy does the gradient estimate become?

    • About 100 times less noisy
    • About 10 times less noisy
    • Not at all less noisy

How it works

  • One question per screen. An answer is final once sent.
  • You see right away whether you were right, with a short explanation.
  • The stopwatch runs: on equal scores, the faster player ranks first.
  • Only your best attempt counts, so replaying is never risky.

About this quiz

A pollster who wants to know how a country will vote does not phone every citizen. A few well-chosen calls give a good estimate at a tiny fraction of the cost, and a few more calls make it better, but with diminishing returns. Training a neural network faces the same trade-off. The exact gradient needs every training example, which becomes absurdly slow when there are millions of them. Stochastic gradient descent, usually shortened to SGD, replaces that exact answer with a cheap, slightly wrong one and takes many more steps.

This quiz explores the idea from its simplest form, one example per update, to the form used almost everywhere, a small group of examples called a mini-batch. You will meet the epoch, the unit that counts one full pass over the data. You will see why a noisy gradient can still be a good guide, why it can sometimes even help, and what happens to the quality of the estimate when you enlarge the batch. You will also see how practical details such as the order of the data and the hardware it runs on enter the decision.

The questions are scenario based. A data set is ordered by date. A team's log shows updates arriving one at a time from a sensor. A model's batch size is multiplied by a large number and someone asks how much quieter the gradient becomes. Each case tests whether you can reason about the method, which is more valuable than remembering its name.

Typical misunderstandings are worth knowing in advance. Many people believe that a noisier gradient is always a defect, or that doubling the batch size halves the noise, or that the order of examples is irrelevant if enough passes are made. None of these holds, and seeing why gives you good instincts for choosing a batch size and for diagnosing odd training curves. There is a further reason the topic deserves attention. Deep learning gets much of its power from very large data sets, so the cost of one update is the quantity that decides whether an idea is practical or not. A method that handles a million examples as cheaply as a thousand changes what is possible, and understanding how SGD achieves this explains why nearly every large model is trained with a variant of it. The same understanding helps you read learning curves, because the jitter you see in the error from one step to the next is often the visible trace of the noise described here.

The quiz suits learners who have met gradient descent and wonder how it scales, and practitioners who set a batch size by habit and want to understand the choice. It involves no formulas. There are 10 questions, each with an explanation, and it takes about four minutes.

Questions and answers

›How long does the quiz take?

About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. Each answer comes with a short explanation, so you learn even from the questions you miss.

›Do I need to know ordinary gradient descent first?

It helps to know that gradient descent repeatedly steps against the slope of the error. If you have taken the quiz on batch gradient descent you are well prepared, but each question here explains the terms it uses, so it is also fine as a first contact.

›What is stochastic gradient descent?

It is gradient descent in which each update is based on a small part of the training data instead of all of it. In its purest form, a single example is used per update. The word stochastic refers to the fact that the gradient it uses is a random estimate, which varies with the examples chosen. On average the estimate points the right way, even though any single one may not.

›What is an epoch?

An epoch is one complete pass through the training set, with every example used once. How many updates that involves depends on how many examples are used per update. Training normally runs for many epochs, and monitoring the error after each epoch is a convenient way of following progress and deciding when to stop.

›What is online gradient descent?

It is the name used when examples arrive as a continuing stream, such as readings from a sensor or events in a service, and the weights are adjusted as each one comes in. The model keeps learning without ever needing the whole data set in memory, and it can follow changes in the data over time.

›Why use a mini-batch instead of a single example?

One example gives a very noisy estimate of the full gradient. A mini-batch averages over several examples, which smooths the estimate, while still being much cheaper than using everything. It also lets modern hardware work on many examples simultaneously. The best size balances the quality of the estimate against the cost of computing it.

›Does a bigger batch always mean better training?

A bigger batch gives a more accurate estimate of the gradient, but the benefit shrinks as the batch grows, so each extra example is worth less than the one before. Meanwhile the cost of a step keeps rising in direct proportion. Beyond a certain point you pay a lot for very little, and you also take fewer steps in a given time, which is why moderate sizes are popular.

›Why does the order of the examples matter?

Raw data are often stored in a pattern, perhaps sorted by date, source or label. A mini-batch drawn from one stretch of the file then resembles a narrow slice of the data, not the whole, and the update can lurch in a misleading direction. Shuffling before batching restores the mixture that each step is supposed to represent.

More quizzes