amici.gradient_check¶
Finite Difference Check¶
This module provides functions to automatically check correctness of amici computed sensitivities using finite difference approximations
Functions Summary
|
|
|
Compares computed values against expected values and provides rich output information. |
|
Finite differences check for likelihood gradient. |
|
Checks the computed sensitivity based derivatives against a finite difference approximation. |
|
Checks whether rdata[field] agrees with expected according to provided tolerances. |
Functions
-
amici.gradient_check.check_close(result, expected, assert_fun, atol, rtol, field, ip=None)[source]¶ Compares computed values against expected values and provides rich output information.
- Parameters
result (
numpy.array) – computed valuesexpected (
numpy.array) – expected valuesfield (
str) – rdata field for which the gradient is checked, only for error reportingassert_fun (
typing.Callable) – function that asserts the return values of comparison, enables passing of custom assert function from testing frameworksatol (
float) – absolute tolerance for comparisonrtol (
float) – relative tolerance for comparisonip (
typing.Optional[int]) – parameter index
- Return type
-
amici.gradient_check.check_derivatives(model, solver, edata=None, assert_fun=<function assert_fun>, atol=0.0001, rtol=0.0001, epsilon=0.001, check_least_squares=True, skip_zero_pars=False)[source]¶ Finite differences check for likelihood gradient.
- Parameters
model (
amici.amici.Model) – amici modelsolver (
amici.amici.Solver) – amici solveredata (
typing.Optional[amici.ExpData]) – exp dataassert_fun (
typing.Optional[typing.Callable]) – function that asserts the return values of comparison, enables passing of custom assert function from testing frameworksatol (
typing.Optional[float]) – absolute tolerance for comparisonrtol (
typing.Optional[float]) – relative tolerance for comparisonepsilon (
typing.Optional[float]) – finite difference step-sizecheck_least_squares (
bool) – whether to check least squares related values.skip_zero_pars (
bool) – whether to perform FD checks for parameters that are zero
- Return type
-
amici.gradient_check.check_finite_difference(x0, model, solver, edata, ip, fields, assert_fun, atol=0.0001, rtol=0.0001, epsilon=0.001)[source]¶ Checks the computed sensitivity based derivatives against a finite difference approximation.
- Parameters
x0 (
typing.Sequence[float]) – parameter value at which to check finite difference approximationmodel (
amici.amici.Model) – amici modelsolver (
amici.amici.Solver) – amici solveredata (
amici.ExpData) – exp dataip (
int) – parameter indexfields (
typing.List[str]) – rdata fields for which to check the gradientassert_fun (
typing.Callable) – function that asserts the return values of comparison, enables passing of custom assert function from testing frameworksatol (
typing.Optional[float]) – absolute tolerance for comparisonrtol (
typing.Optional[float]) – relative tolerance for comparisonepsilon (
typing.Optional[float]) – finite difference step-size
- Return type
-
amici.gradient_check.check_results(rdata, field, expected, assert_fun, atol, rtol)[source]¶ Checks whether rdata[field] agrees with expected according to provided tolerances.
- Parameters
rdata (
amici.amici.ReturnData) – simulation results as returned byamici.amici.runAmiciSimulation()field (
str) – name of the field to checkexpected (
numpy.array) – expected valuesassert_fun (
typing.Callable) – function that asserts the return values of comparison, enables passing of custom assert function from testing frameworksatol (
float) – absolute tolerance for comparisonrtol (
float) – relative tolerance for comparison
- Return type