Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent fval calculation in gradient check #1547

Open
m-philipps opened this issue Jan 21, 2025 · 1 comment
Open

Inconsistent fval calculation in gradient check #1547

m-philipps opened this issue Jan 21, 2025 · 1 comment

Comments

@m-philipps
Copy link
Contributor

The finite difference calculation in check_grad uses sensi_orders=(0, 1) (or higher) for fval and sensi_orders=(0,) for fval_p and fval_m.

# finite differences
fd_f_ix = (fval_p - fval) / eps
fd_b_ix = (fval - fval_m) / eps
fd_c_ix = (fval_p - fval_m) / (2 * eps)

In some cases, e.g. where the gradient calculation via adjoint states requires a smaller step size, this might affect the function value.

To make it consistent, the calculation of fval_p and fval_m should use the same sensi_orders as fval. However, for difficult problems that might introduce some overhead in computation.

@m-philipps m-philipps changed the title Inconsisten gradiet calculation in gradient check Inconsisten fval calculation in gradient check Jan 21, 2025
@m-philipps m-philipps changed the title Inconsisten fval calculation in gradient check Inconsistent fval calculation in gradient check Jan 21, 2025
@dweindl
Copy link
Member

dweindl commented Jan 21, 2025

Related to #1487

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants