From c949da2d67ec2bc0d13138415bce7a6a539a82c5 Mon Sep 17 00:00:00 2001 From: James Hensman Date: Fri, 11 Jan 2013 17:58:19 +0000 Subject: [PATCH] allowed the gradchecker to return the gradient ratio Just to help with debugging. --- GPy/core/model.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/GPy/core/model.py b/GPy/core/model.py index 183cf0f0..cd37ea33 100644 --- a/GPy/core/model.py +++ b/GPy/core/model.py @@ -286,7 +286,7 @@ class model(parameterised): return '\n'.join(s) - def checkgrad(self, verbose=False, include_priors=False, step=1e-6, tolerance = 1e-3, *args): + def checkgrad(self, verbose=False, include_priors=False, step=1e-6, tolerance = 1e-3, return_ratio=False, *args): """ Check the gradient of the model by comparing to a numerical estimate. If the overall gradient fails, invividual components are tested. @@ -306,12 +306,12 @@ class model(parameterised): gradient = self.extract_gradients() numerical_gradient = (f1-f2)/(2*dx) - ratio = (f1-f2)/(2*np.dot(dx,gradient)) + global_ratio = (f1-f2)/(2*np.dot(dx,gradient)) if verbose: - print "Gradient ratio = ", ratio, '\n' + print "Gradient ratio = ", global_ratio, '\n' sys.stdout.flush() - if (np.abs(1.-ratio)