Limited differential gradient: the smaller the step, the less accurate

Compares the forward-to-central differential error order and designs a recognizable gradient verification.

Thematic shorts • IntroductionCollate in 2 self-measured2 First-hand sources
Start Body
Learning objectives and first steps2 objectives . 1 first fix

Try to do it after reading

  • Compare the point of error between forward and centre
  • Design a recognizable gradient verification

Suggested first

  • Vector and Matrix Operations

Digital verification is good for finding out what's wrong

When writing losses, custom calculations or complex parameter sharing structures, the limited differential provides a gradient check path that does not depend on the same reverse transmission. It recalculates the function by making a small disturbance value for input, which is similar to a single-order guide. This inspection is costly and usually only applies to small samples, small directions or randomly selected parameters, but it is well suited to detect errors in symbols, conversions and approximation.

Accurate error analysis for three functions

Take f(x) = x3 and have a genuine lead of 12 at x = 2. Upward differentials are 12+6 h+h2; The center score is 12 plus. h ²。 If h = 0.1, respectively 12.61 and 12.01; If h = 0.01, the difference in the centre becomes 12.0001. Here one can see directly the first step error of the forward method and the second step of the central method, rather than just a graphic feeling that a curve is smoother. In precision count calculations, the length of the concession can improve the cut-off error; The floating point calculation also faces a loss of validity resulting from the reduction of two values close to the value. When the margin is close to rounding up the accuracy, it is divided by a smaller step to magnify error. Several levels of quantification should be tried in order to find areas where the results are stable, rather than permanently designating a very small constant.

Both absolute and relative errors

When the true gradient is close to zero, the relative error may be large, even if the absolute difference is already small; When the gradient is large, it may be too harsh to look at absolute differences. The units that are subject to the check can be reported simultaneously as absolute, standardized and variable. Different scales of magnitude may also be required for different groups of parameters.

Make sure that two functions call comparable

Verification should be done with fixed data, random seeds, model models and all operations that change state. If each disturbance is randomly re-sampled, the function difference mixes the sampling noise; If you update your statistics in a homogenized layer, you may also not have the same function before and after. The determination of certainty should be separated before the actual training behaviour is restored on a case-by-case basis. In absolute zero, max parallel or discrete branch switching places, the central difference may reflect an average of the two sides and may not necessarily correspond to the sub-gradient agreement used in the frame. Inconsistencies occur when the boundary is checked and the error is judged. Value checks also indicate the consistency of the selected points and directions and do not justify the integrity of the network, all inputs or training closings.

f′(x)≈f(x+h)−f(x−h)2h

Self-measurement and provocator

Why is there no 6 h difference in this case centre?

The symmetric symmetry of positive or negative disturbances offsets the corresponding first-order cut-off, leaving only h2 error.

Will h continue to shrink from one in a million, always closer to the true number?

No, I won't. The rounding-down and subtraction will gradually prevail, and several steps to stabilize the area should be observed and the function state fixed.

Sources and reconciliations

Definitions, methods and interfaces are available.

  1. Mathematics for Machine Learning — author textbook
  2. MIT 18.02SC Multivariable Calculus

Figures and calculations are reorganized according to this chapter. Mathematical measurements, framework operations and real business effects are described separately in the body of the text.

← Back to the knowledge directory
Ask Max Ask about this site
Ask Max ↗

Opening the assistant…

Paper figure

Photo comments

LEAVE A NOTE

About this photograph

Connecting to the discussion board…

    Comments become public after moderation. You can delete your own comments from this browser.
    No email is required. Clearing cookies prevents this browser from claiming earlier comments.

    MAX WANG / INDEX

    Find something

    Enter a keyword, or explore the directory below.