What is the purpose of numerical gradient checking using finite differences?

Quick Overview

Asks why engineers compare backpropagation gradients against finite-difference estimates and how to run that check well. Tests knowledge of the centered difference formula, relative error thresholds, step size and precision choices, non-differentiable points, and why the check is only used for debugging.

What is the purpose of numerical gradient checking using finite differences?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What is the purpose of numerical gradient checking using finite differences? Explain how you would run the check and how you would read its result. ```hint Two ways to get a derivative Think about what can go wrong when you derive and code a backward pass by hand, and how you could estimate the same derivative using only forward evaluations of the loss. ``` ### What a Strong Answer Covers - What is compared with what, and which kinds of bugs the check catches - The finite-difference formula, and why the centered version is preferred over a one-sided one - How to compare the two gradients and what size of error points to a bug - Practical settings: numeric precision, the choice of step size, randomness, non-differentiable points - Why the check is a debugging tool and not part of training ### Follow-up Questions - Why does making the step size very small eventually make the numerical gradient less accurate? - A network with ReLU activations shows a relative error around 1e-3 on a few parameters. Is that a bug? - How would you check the gradients of a model with millions of parameters at a reasonable cost? - Why can a gradient check pass while the model still trains badly?

Overview: Asks why engineers compare backpropagation gradients against finite-difference estimates and how to run that check well. Tests knowledge of the centered difference formula, relative error thresholds, step size and precision choices, non-differentiable points, and why the check is only used for debugging.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

What is the purpose of numerical gradient checking using finite differences? Explain how you would run the check and how you would read its result.

What a Strong Answer Covers Guidance

  • What is compared with what, and which kinds of bugs the check catches
  • The finite-difference formula, and why the centered version is preferred over a one-sided one
  • How to compare the two gradients and what size of error points to a bug
  • Practical settings: numeric precision, the choice of step size, randomness, non-differentiable points
  • Why the check is a debugging tool and not part of training

Follow-up Questions Guidance

  • Why does making the step size very small eventually make the numerical gradient less accurate?
  • A network with ReLU activations shows a relative error around 1e-3 on a few parameters. Is that a bug?
  • How would you check the gradients of a model with millions of parameters at a reasonable cost?
  • Why can a gradient check pass while the model still trains badly?