1 from __future__
import print_function, division
3 import pyexotica
as exo
10 x_plus = method(x + eps/2.0, arg)
11 x_minus = method(x - eps/2.0, arg)
12 dx = (x_plus - x_minus) / eps
17 for _
in range(NUM_TESTS):
18 x = np.random.random((1,))
19 dx_analytic = df(x, arg)
22 np.testing.assert_allclose(dx_analytic, dx_numdiff, rtol=1e-3)
26 for delta
in [0.001, 0.01, 0.1, 1.0, 10.0]:
28 exo.Tools.SparseCosts.huber_jacobian, delta)
30 exo.Tools.SparseCosts.huber_hessian, delta)
34 for alpha
in [1.0, 10.0]:
36 exo.Tools.SparseCosts.smooth_l1_jacobian, alpha)
38 exo.Tools.SparseCosts.smooth_l1_hessian, alpha)
41 if __name__ ==
"__main__":
def check_derivative_1d(f, df, arg)
def num_diff_1d(method, x, arg)