diff --git a/GPy/core/model.py b/GPy/core/model.py index 90294a73..15cb3f79 100644 --- a/GPy/core/model.py +++ b/GPy/core/model.py @@ -263,7 +263,7 @@ class Model(Parameterized): sgd.run() self.optimization_runs.append(sgd) - def _checkgrad(self, target_param=None, verbose=False, step=1e-6, tolerance=1e-3): + def _checkgrad(self, target_param=None, verbose=False, step=1e-6, tolerance=1e-3, df_tolerance=1e-12): """ Check the gradient of the ,odel by comparing to a numerical estimate. If the verbose flag is passed, individual @@ -322,7 +322,7 @@ class Model(Parameterized): except NotImplementedError: names = ['Variable %i' % i for i in range(len(x))] # Prepare for pretty-printing - header = ['Name', 'Ratio', 'Difference', 'Analytical', 'Numerical'] + header = ['Name', 'Ratio', 'Difference', 'Analytical', 'Numerical', 'dF_ratio'] max_names = max([len(names[i]) for i in range(len(names))] + [len(header[0])]) float_len = 10 cols = [max_names] @@ -359,6 +359,8 @@ class Model(Parameterized): f1 = self._objective(xx) xx[xind] -= 2.*step f2 = self._objective(xx) + df_ratio = np.abs((f1-f2)/f1) + df_unstable = df_ratio