Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve kernel tests #867

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 6 additions & 20 deletions GPy/testing/kernel_tests.py
Expand Up @@ -176,8 +176,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Positive definite check failed for " + kern.name + " covariance function."))
pass_checks = False
assert(result)
return False


if verbose:
print("Checking gradients of K(X, X) wrt theta.")
Expand All @@ -188,8 +187,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
print(("Gradient of K(X, X) wrt theta failed for " + kern.name + " covariance function. Gradient values as follows:"))
Kern_check_dK_dtheta(kern, X=X, X2=None).checkgrad(verbose=True)
pass_checks = False
assert(result)
return False


if verbose:
print("Checking gradients of K(X, X2) wrt theta.")
Expand All @@ -205,8 +203,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
print(("Gradient of K(X, X) wrt theta failed for " + kern.name + " covariance function. Gradient values as follows:"))
Kern_check_dK_dtheta(kern, X=X, X2=X2).checkgrad(verbose=True)
pass_checks = False
assert(result)
return False


if verbose:
print("Checking gradients of Kdiag(X) wrt theta.")
Expand All @@ -222,8 +219,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
print(("Gradient of Kdiag(X) wrt theta failed for " + kern.name + " covariance function. Gradient values as follows:"))
Kern_check_dKdiag_dtheta(kern, X=X).checkgrad(verbose=True)
pass_checks = False
assert(result)
return False


if verbose:
print("Checking gradients of K(X, X) wrt X.")
Expand All @@ -241,9 +237,8 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Gradient of K(X, X) wrt X failed for " + kern.name + " covariance function. Gradient values as follows:"))
testmodel.checkgrad(verbose=True)
assert(result)

pass_checks = False
return False

if verbose:
print("Checking gradients of K(X, X2) wrt X.")
Expand All @@ -261,9 +256,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Gradient of K(X, X2) wrt X failed for " + kern.name + " covariance function. Gradient values as follows:"))
testmodel.checkgrad(verbose=True)
assert(result)
pass_checks = False
return False

if verbose:
print("Checking gradients of Kdiag(X) wrt X.")
Expand All @@ -282,8 +275,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
print(("Gradient of Kdiag(X) wrt X failed for " + kern.name + " covariance function. Gradient values as follows:"))
Kern_check_dKdiag_dX(kern, X=X).checkgrad(verbose=True)
pass_checks = False
assert(result)
return False


if verbose:
print("Checking gradients of dK(X, X2) wrt X2 with full cov in dimensions")
Expand All @@ -301,9 +293,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Gradient of dK(X, X2) wrt X failed for " + kern.name + " covariance function. Gradient values as follows:"))
testmodel.checkgrad(verbose=True)
assert(result)
pass_checks = False
return False

if verbose:
print("Checking gradients of dK(X, X) wrt X with full cov in dimensions")
Expand All @@ -321,9 +311,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Gradient of dK(X, X) wrt X with full cov in dimensions failed for " + kern.name + " covariance function. Gradient values as follows:"))
testmodel.checkgrad(verbose=True)
assert(result)
pass_checks = False
return False

if verbose:
print("Checking gradients of dKdiag(X, X) wrt X with cov in dimensions")
Expand All @@ -341,9 +329,7 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb
if not result:
print(("Gradient of dKdiag(X, X) wrt X with cov in dimensions failed for " + kern.name + " covariance function. Gradient values as follows:"))
testmodel.checkgrad(verbose=True)
assert(result)
pass_checks = False
return False

return pass_checks

Expand Down