-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce Wrapper (instead of specializing kernel evaluation on DiffP…
…t) (#10) * enableDiffWrap instead of general * jldoctest * trim jldoctest * warning docs, shorten name * identify broken tests * push broken state (upstream issue) JuliaGaussianProcesses/KernelFunctions.jl#517
- Loading branch information
1 parent
4fb8d88
commit 917c4da
Showing
5 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,39 @@ | ||
@testset "diffKernel" begin | ||
@testset "smoke test" begin | ||
k = MaternKernel() | ||
k(1, 1) | ||
k = EnableDiff(MaternKernel()) | ||
k2 = MaternKernel() | ||
@test k(1, 1) == k2(1, 1) | ||
k(1, (1, partial(1, 1))) # Cov(Z(x), ∂₁∂₁Z(y)) where x=1, y=1 | ||
k(([1], partial(1)), [2]) # Cov(∂₁Z(x), Z(y)) where x=[1], y=[2] | ||
k(([1, 2], partial(1)), ([1, 2], partial(2)))# Cov(∂₁Z(x), ∂₂Z(y)) where x=[1,2], y=[1,2] | ||
end | ||
|
||
@testset "Sanity Checks with $k" for k in [SEKernel()] | ||
@testset "Sanity Checks with $k1" for k1 in [ | ||
SEKernel(), | ||
MaternKernel(ν=5), | ||
RationalQuadraticKernel(), | ||
SEKernel() + RationalQuadraticKernel() | ||
] | ||
k = EnableDiff(k1) | ||
for x in [0, 1, -1, 42] | ||
# for stationary kernels Cov(∂Z(x) , Z(x)) = 0 | ||
@test k((x, partial(1)), x) ≈ 0 | ||
# correlation with self should be positive | ||
## This fails for Matern and RationalQuadraticKernel | ||
# because its implementation branches on x == y resulting in a zero derivative | ||
# (cf. https://github.com/JuliaGaussianProcesses/KernelFunctions.jl/issues/517) | ||
@test k((x, partial(1)), (x, partial(1))) > 0 | ||
|
||
# the slope should be positively correlated with a point further down | ||
@test k( | ||
(x, partial(1)), # slope | ||
x + 1e-1, # point further down | ||
x + 1e-2, # point further down | ||
) > 0 | ||
|
||
# correlation with self should be positive | ||
@test k((x, partial(1)), (x, partial(1))) > 0 | ||
@testset "Stationary Tests" begin | ||
@test k((x, partial(1)), x) == 0 # expect Cov(∂Z(x) , Z(x)) == 0 | ||
|
||
@testset "Isotropic Tests" begin | ||
@test k(([1, 2], partial(1)), ([1, 2], partial(2))) == 0 # cross covariance should be zero | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters