DeepLLM Quiz
Deep Learning

Four ways to compute a gradient: by hand, numerically, symbolically or automatically

10 questions comparing hand-derived backpropagation, numerical, symbolic and automatic differentiation, including expression swell and control flow.

  • 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

    A function is built from a long chain of nested products. When a symbolic tool differentiates it, what is likely to happen to the size of the result?

    • It stays the same size as the original
    • It becomes smaller, because derivatives simplify things
    • It grows enormously, with the same sub-expressions repeated many times

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 research lab changes its network design every week: a new kind of layer on Monday, a different loss on Wednesday, a loop that repeats a block a variable number of times on Friday. Every change alters the formula for the output, and the gradient must follow. If an engineer had to rederive and re-code the gradient by hand each time, the lab would spend more time on calculus than on research. The fact that this chore has all but vanished from daily practice is one of the quiet reasons why deep learning moved so fast.

This quiz compares the four ways of getting a gradient. The first is the traditional one: work out the backpropagation equations on paper and code them. The second is numerical differentiation, which nudges each parameter and watches the result. The third is symbolic differentiation, in which software applies the rules of calculus to a formula and produces another formula. The fourth is automatic differentiation, which looks like the third but is fundamentally different, because it generates code for computing derivatives rather than an expression for them.

You will see what each approach costs, what it can and cannot cope with, and why one of them has become the default in modern frameworks. Several of the questions are scenarios: a function built from nested products whose derivative balloons, a model whose forward code contains a loop, a project in which two copies of the same logic must be kept in step. Others ask about accuracy and about which approach is best placed to check the others.

A few misconceptions are worth challenging. Symbolic and automatic differentiation are easily confused, but they differ in what they output and in what they can handle. Numerical differentiation is often written off as useless, yet it earns its place as a debugging tool. And hand-derived gradients are not wrong or obsolete, only slow to produce and easy to get subtly wrong. Knowing the options also changes how you read documentation. Terms like tape, trace, graph and differentiable programming all describe pieces of the same fourth approach, and understanding what the approach promises tells you what a framework can and cannot guarantee. If you ever write a custom operation, you will need to supply its derivative yourself, and you will know why. If you ever wonder why a gradient is slightly off, you will know where the error could have come from in each of the four methods.

The quiz suits learners who use a framework that computes gradients automatically and wonder what happens underneath, and developers choosing a tool for their own project. It needs no mathematics. 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 is followed by an explanation, and together they make a quick comparison chart of the four methods.

›Do I need to know how backpropagation works?

It helps to know that backpropagation is a way of computing a network's gradient efficiently, and the quiz on how it works covers that. For this quiz, the focus is on the different ways of obtaining the same result, and no calculus is required.

›What does it mean to derive backpropagation by hand?

It means working out the equations for the gradient on paper for a particular network and writing code that implements them, separately from the code that evaluates the network. If done carefully, it gives fast, accurate code. The cost is the time spent on the derivation, the risk of errors and the need to change both pieces of code whenever the model changes.

›What is symbolic differentiation?

It is the use of computer algebra to apply the rules of calculus mechanically to a formula, producing a new formula for the derivative. The result is exact and avoids human error. However, the derivative formulas can become far longer than the original, and the method needs the function to be written as a closed-form expression.

›What is expression swell?

It is the growth of symbolic derivatives. When a function is a product of two parts, its derivative involves both parts again, so work done for the function is repeated for its derivative. If the parts are themselves products, the duplication nests, and the expression can become exponentially longer than the original. Evaluating it is then correspondingly slow.

›What is automatic differentiation?

It is a technique in which the computer takes the code that evaluates a function and automatically generates code that also computes the derivatives. It does not try to find a neat formula. By reusing the intermediate values from the evaluation, it avoids the repeated work that plagues symbolic methods, and it follows the code through branches, loops and function calls.

›Why is it called automatic and not numerical?

Because its results are not approximations. Automatic differentiation applies the exact rules of calculus to each elementary operation in the code, so its answers are accurate to machine precision. Numerical differentiation, by contrast, estimates a derivative from small changes and is limited by the choice of step and by round-off.

›Which method should I use in practice?

For training, automatic differentiation is the standard, since it is accurate, efficient and requires no extra work when the model changes. Numerical differentiation remains valuable for checking that other implementations are correct, and symbolic tools are useful when a closed-form expression of the derivative is wanted for its own sake.

More quizzes