mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-06-11 15:15:15 +02:00
a cleaner test
This commit is contained in:
parent
d6a56a6f0b
commit
fc8705104b
2 changed files with 3 additions and 6 deletions
|
|
@ -61,7 +61,6 @@ class Prod(CombinationKernel):
|
|||
for p in self.parts:
|
||||
p.update_gradients_full(k/p.K(X,X2),X,X2)
|
||||
except FloatingPointError:
|
||||
#print "WARNING: gradient calculation falling back to slow version due to zero-valued kernel"
|
||||
for combination in itertools.combinations(self.parts, len(self.parts) - 1):
|
||||
prod = reduce(np.multiply, [p.K(X, X2) for p in combination])
|
||||
to_update = list(set(self.parts) - set(combination))[0]
|
||||
|
|
|
|||
|
|
@ -408,11 +408,9 @@ class KernelTestsProductWithZeroValues(unittest.TestCase):
|
|||
lin = GPy.kern.Linear(2)
|
||||
bias = GPy.kern.Bias(2)
|
||||
k = lin * bias
|
||||
m = GPy.models.GPRegression(X, Y, kernel=k)
|
||||
try:
|
||||
m.optimize()
|
||||
except np.linalg.LinAlgError:
|
||||
self.fail("Zero-valued kernel raised exception!")
|
||||
k.update_gradients_full(1, X)
|
||||
self.assertFalse(np.isnan(k['linear.variances'].gradient),
|
||||
"Gradient resulted in NaN")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue