Reputation: 2583
We have found that several components of our code fail the gradient check when using forward or backward differencing, but pass when using the more accurate central differencing. To remedy this we have modified the default in these functions in our version of the code to use central differencing.
We would like to request that the finite differencing method used by the derivative check methods be made an option so that the tests can pass when run by other users.
Upvotes: 1
Views: 90
Reputation: 5710
Although you can control behavior on an individual variable level via meta-data, or a whole component level via FD options, its also reasonable to set specific options via kwargs to check_partial_derivs. This is something we can work on, though it won't be super high priority for us at the moment.
Upvotes: 2
Reputation: 2202
You should already be able to do this on an individual variable basis by specifying the form
in the add_param
for the variables you want to central difference.
self.add_param('x2', 3.0, form = 'central')
Alternatively, you can set them for all params in a single component by:
self.fd_options['form'] = 'central'
The check_partial_derivatives
will definitely pick this up. Ultimately check_total_derivatives
should also pick it up, but there is still an outstanding bug about what happens when you specify different values in multiple targets that are connected to a single IndepVarComp source -- which one does it use -- it uses the first one it finds right now.
You can also set step_type
and step_size
this way.
Upvotes: 2