-
Notifications
You must be signed in to change notification settings - Fork 41
Adds kernel related to the Intrinsic Coregionalization Model #263
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
Merged
willtebbutt
merged 67 commits into
JuliaGaussianProcesses:master
from
david-vicente:master
Jun 2, 2021
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
cdfae04
Adds first version of Intrinsic Coregionalization Multi-Output Kernel.
david-vicente 5e4efc3
Changes the name of the kernel. Removes "implementation code" for the
david-vicente fa3c124
Adds tests for CoregionMOKernel.
david-vicente 1f89b00
Adds coregion tests to runtests file.
david-vicente 0704989
Adds docstring to coregion kernel.
david-vicente 5574ec9
Update src/mokernels/coregion.jl
david-vicente ac411ac
Makes notation in docstring conformant with the rest of the package.
david-vicente 4500e21
Makes code respect formating style guidelines.
david-vicente 9796500
Merge branch 'master' of https://github.com/4aHxKzD/KernelFunctions.jl
david-vicente d4a93c7
Merge remote-tracking branch 'upstream/master'
david-vicente eaeffb4
Adds Coregion kernel to docs file.
david-vicente 570655c
Merge branch 'JuliaGaussianProcesses:master' into master
david-vicente 13d2584
Removes unused argument.
david-vicente e6311d6
Creates new methods for Finitedifferences.to_vec to deal with the
david-vicente a5fc6b2
Creates new methods to compute the jacobian of multioutput kernels.
david-vicente 13cbe37
Formatting.
david-vicente 81c2476
Reworkes to_vec so that the reimplementation of _jvp and jacobian is
david-vicente 72f124e
Renames kernel.
david-vicente cbf4cba
Changes all affected files by the kernel renaming.
david-vicente 30c2a5c
Adds test_interface method to generate inputs for MOkernels.
david-vicente 8765077
Makes IntrinsicCoregionMOKernel use the standard suit of tests.
david-vicente 51a0a7e
Improves MOkernels tests to test different outputs dimensions.
david-vicente df66dc0
Passes RNG object to rand method.
david-vicente 936bd94
Adds MOKernel methods for testfunction and testdiagfunction.
david-vicente e10059a
Adds test_FiniteDiff method for MOKernels.
david-vicente 01490b7
Changes test_FiniteDiff for MOKernel signature to have the same number
david-vicente 2e04b29
Corrects bug in tests where the created covariance matrix between out…
david-vicente 28d912d
Adapts compare_gradient for MOKernels.
david-vicente 6bef1b7
Adapts test_AD for MOKernels.
david-vicente a6689ad
Adapts test_ADs for MOKernels.
david-vicente bc58b16
Corrects type annotation.
david-vicente 53f4d65
Corrects argument splatting.
david-vicente dcabde9
Rewrites variables as named tuple.
david-vicente b029763
Updates arguments.
david-vicente b31625f
Adds standardised AD tests for IntrinsicCoregionMOKernel.
david-vicente 4a603e2
Adds include of finitedifferences file to runtests.
david-vicente 01e31c1
Passes dims argument.
david-vicente d823057
Formatting.
david-vicente 4988667
Formatting.
david-vicente f30273e
Corrects a bug where the wrong tuple fields were used.
david-vicente bf9d217
Corrects test.
david-vicente 1ac68f6
Implements @theogf approach to testing gradients of MOkernels.
david-vicente 90db07d
With new approach this file is not needed.
david-vicente 7928803
Correctly implement @theogf approach to MOkernels AD testing.
david-vicente bf1ab84
Changes tests to use SqExponentialKernel instead of
david-vicente b5cbab8
Deletes unsused include.
david-vicente a627f76
Simplifies docstring.
david-vicente af05c2a
Improves error message.
david-vicente 4965979
Deletes file because we currently pass just the Real part to gradient
david-vicente cb27119
Adds kernel and number of outputs when printing Icoregionkernel.
david-vicente 85c86f7
Adds test for different inputs as arguments.
david-vicente dbd7f27
Stops infringing character limit.
david-vicente 93e9b2c
Further simplify docstring.
david-vicente 9ab8e60
Adds tests.
david-vicente d3ef272
Merge branch 'JuliaGaussianProcesses:master' into master
david-vicente 16a773b
Deletes unuseful tests.
david-vicente 160a38e
Updates print test.
david-vicente bb8adc2
Stops using interpolations.
david-vicente 6fa2404
Creates constructor with keyword arguments.
david-vicente fede680
Restore constructor.
david-vicente a86529b
Deletes non kwargs outer constructor.
david-vicente 169234e
Formatting.
david-vicente 3f211b2
Updates code to be in consistent with kwargs constructor.
david-vicente 5db59ef
Updates docstring.
david-vicente 6a1e950
Merge branch 'master' into master
devmotion 6d46be5
Update Project.toml
devmotion b160810
Formatting.
david-vicente File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -133,4 +133,5 @@ NormalizedKernel | |
| MOKernel | ||
| IndependentMOKernel | ||
| LatentFactorMOKernel | ||
| IntrinsicCoregionMOKernel | ||
| ``` | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| @doc raw""" | ||
| IntrinsicIntrinsicCoregionMOKernel(; kernel::Kernel, B::AbstractMatrix) | ||
|
|
||
| Kernel associated with the intrinsic coregionalization model. | ||
|
|
||
| # Definition | ||
|
|
||
| For inputs ``x, x'`` and output dimensions ``p, p'``, the kernel is defined as[^ARL] | ||
| ```math | ||
| k\big((x, p), (x', p'); B, \tilde{k}\big) = B_{p, p'} \tilde{k}\big(x, x'\big), | ||
| ``` | ||
| where ``B`` is a positive semidefinite matrix of size ``m \times m``, with ``m`` being the | ||
| number of outputs, and ``\tilde{k}`` is a scalar-valued kernel shared by the latent | ||
| processes. | ||
|
|
||
| [^ARL]: M. Álvarez, L. Rosasco, & N. Lawrence (2012). [Kernels for Vector-Valued Functions: a Review](https://arxiv.org/pdf/1106.6251.pdf). | ||
| """ | ||
| struct IntrinsicCoregionMOKernel{K<:Kernel,T<:AbstractMatrix} <: MOKernel | ||
| kernel::K | ||
| B::T | ||
|
|
||
| function IntrinsicCoregionMOKernel{K,T}(kernel::K, B::T) where {K,T} | ||
| @check_args( | ||
| IntrinsicCoregionMOKernel, | ||
| B, | ||
| eigmin(B) >= 0, | ||
| "B has to be positive semi-definite" | ||
| ) | ||
| return new{K,T}(kernel, B) | ||
| end | ||
| end | ||
|
|
||
| function IntrinsicCoregionMOKernel(; kernel::Kernel, B::AbstractMatrix) | ||
| return IntrinsicCoregionMOKernel{typeof(kernel),typeof(B)}(kernel, B) | ||
| end | ||
|
|
||
| function (k::IntrinsicCoregionMOKernel)((x, px)::Tuple{Any,Int}, (y, py)::Tuple{Any,Int}) | ||
| return k.B[px, py] * k.kernel(x, y) | ||
| end | ||
|
|
||
| function Base.show(io::IO, k::IntrinsicCoregionMOKernel) | ||
| return print( | ||
| io, "Intrinsic Coregion Kernel: ", k.kernel, " with ", size(k.B, 1), " outputs" | ||
| ) | ||
| end |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| @testset "intrinsiccoregion" begin | ||
| rng = MersenneTwister(123) | ||
|
|
||
| dims = (in=3, out=2, obs=3) | ||
| rank = 1 | ||
|
|
||
| A = randn(dims.out, rank) | ||
| B = A * transpose(A) + Diagonal(rand(dims.out)) | ||
|
|
||
| X = [(rand(dims.in), rand(1:(dims.out))) for i in 1:(dims.obs)] | ||
|
|
||
| kernel = SqExponentialKernel() | ||
| icoregionkernel = IntrinsicCoregionMOKernel(; kernel=kernel, B=B) | ||
|
|
||
| @test icoregionkernel.B == B | ||
| @test icoregionkernel.kernel == kernel | ||
| @test icoregionkernel(X[1], X[1]) ≈ B[X[1][2], X[1][2]] * kernel(X[1][1], X[1][1]) | ||
| @test icoregionkernel(X[1], X[end]) ≈ B[X[1][2], X[end][2]] * kernel(X[1][1], X[end][1]) | ||
|
|
||
| KernelFunctions.TestUtils.test_interface( | ||
| icoregionkernel, Vector{Tuple{Float64,Int}}; dim_out=dims.out | ||
| ) | ||
|
|
||
| test_ADs(icoregionkernel; dims=dims) | ||
|
|
||
| @test string(icoregionkernel) == | ||
| string("Intrinsic Coregion Kernel: ", kernel, " with ", dims.out, " outputs") | ||
| end | ||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.