possible to reduce the relative difference for CheckGradients in optimization (fmincon)?
Mostra commenti meno recenti
When double-checking my Jacobian using CheckGradients, I have a relative maximum difference of, crudely, 4e-6,
and my entries of the Jacobian are in the ballpark 1e-1.
I do not expect that Finite Difference can calculate the first six digits after the decimal correctly as my problem has large second derivatives.
That said, can I reduce the relative difference in CheckGradients from 1e-6 to a different value?
Risposta accettata
Più risposte (1)
Why not just turning off the CheckGradient feature if you are sure your derivatives are correct within a certain error tolerance (which might be larger than 1e-6) ?
5 Commenti
SA-W
il 26 Ott 2022
Torsten
il 26 Ott 2022
If you know which MATLAB function is called to check the gradients, you should be able to find a "1e-6" in the code :-)
SA-W
il 27 Ott 2022
Torsten
il 27 Ott 2022
To me, the fixed value of 1e-6 does not make sense at all. Say, the entries were in the ballpark 1e-6 -- gradient check would work even if the first relevant digit is wrong. On the other hand, if the entries were 1e-1, gradient check fails although the first 4 or 5 digits are correct.
I don't think that 1e-6 is an absolute, but a relative error in the calculation. Thus
|| gradient_MATLAB - gradient_USER || <= eps * ||gradient_MATLAB||
or something similar is checked for
||gradient_MATLAB|| > 1
and
|| gradient_MATLAB - gradient_USER|| <= eps
only for
||gradient_MATLAB|| <= 1
SA-W
il 17 Gen 2023
Categorie
Scopri di più su Choose a Solver in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!