Home Contact Us Site Map  
 
       
    next up previous contents
Next: 5.3.1 Code description Up: 5. Automatic Differentiation Previous: 5.2.5 The control variables   Contents


5.3 The gradient check package

An indispensable test to validate the gradient computed via the adjoint is a comparison against finite difference gradients. The gradient check package pkg/grdchk enables such tests in a straightforward and easy manner. The driver routine grdchk_main is called from the_model_main after the gradient has been computed via the adjoint model (cf. flow chart ???).

The gradient check proceeds as follows: The $ i-$ th component of the gradient $ (\nabla _{u}{\cal J}^T)_i $ is compared with the following finite-difference gradient:

$\displaystyle \left(\nabla _{u}{\cal J}^T \right)_i$    vs. $\displaystyle \quad
\frac{\partial {\cal J}}{\partial u_i} \, = \,
\frac{ {\cal J}(u_i + \epsilon) - {\cal J}(u_i)}{\epsilon}
$

A gradient check at point $ u_i$ may generally considered to be successful if the deviation of the ratio between the adjoint and the finite difference gradient from unity is less than 1 percent,

$\displaystyle 1 \, - \,
\frac{({\rm grad}{\cal J})_i (\text{adjoint})}
{({\rm grad}{\cal J})_i (\text{finite difference})} \, < 1 \%
$



Subsections

mitgcm-support@mitgcm.org
Copyright © 2006 Massachusetts Institute of Technology Last update 2011-01-09