From 3a726341494fd6fa911a45a71b27c7de489cb19f Mon Sep 17 00:00:00 2001 From: Max Zwiessele Date: Sun, 13 Sep 2015 08:42:58 +0100 Subject: [PATCH] Update model.py --- GPy/core/model.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GPy/core/model.py b/GPy/core/model.py index 9d8b89f4..69b56529 100644 --- a/GPy/core/model.py +++ b/GPy/core/model.py @@ -368,9 +368,9 @@ class Model(Parameterized): for nind, xind in zip(param_index, transformed_index): xx = x.copy() xx[xind] += step - f1 = self._objective(xx) + f1 = float(self._objective(xx)) xx[xind] -= 2.*step - f2 = self._objective(xx) + f2 = float(self._objective(xx)) #Avoid divide by zero, if any of the values are above 1e-15, otherwise both values are essentiall #the same if f1 > 1e-15 or f1 < -1e-15 or f2 > 1e-15 or f2 < -1e-15: @@ -378,9 +378,9 @@ class Model(Parameterized): else: df_ratio = 1.0 df_unstable = df_ratio < df_tolerance - numerical_gradient = (f1 - f2) / (2 * step) + numerical_gradient = (f1 - f2) / (2. * step) if np.all(gradient[xind] == 0): ratio = (f1 - f2) == gradient[xind] - else: ratio = (f1 - f2) / (2 * step * gradient[xind]) + else: ratio = (f1 - f2) / (2. * step * gradient[xind]) difference = np.abs(numerical_gradient - gradient[xind]) if (np.abs(1. - ratio) < tolerance) or np.abs(difference) < tolerance: