-
Notifications
You must be signed in to change notification settings - Fork 36
Some improvement and additions to MO kernels #354
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 54 commits into
JuliaGaussianProcesses:master
from
Crown421:mo-improvements
Aug 16, 2021
Merged
Changes from 5 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
8427ae5
Fix type stability of independent kernel
Crown421 1a5ac23
Add convenience functions
Crown421 d79d24b
Add/fix tests
Crown421 4f23240
Suggested change for kernelmatrix computation
Crown421 a33c312
Add results to test script
Crown421 a729c01
Switching to new kernelmatrix for independent kernel, tests
Crown421 e1f92a8
Change type stability
Crown421 e7d7db9
New kernelmatrix for IntrinsicCoregion kernel, tests
Crown421 ee69c6e
JuliaFormatter
Crown421 d1d8d45
Improve code reuse, Traits
Crown421 d80453c
Use FillArray
Crown421 06cbb3d
Remove traits, move to explicit function
Crown421 d03b951
Relax matrixkernel types
Crown421 c8f8093
Adjust MOInput specifications
Crown421 cd6dedc
Merge branch 'mo-improvements' of github.com:Crown421/KernelFunctions…
Crown421 8b7410a
Merge branch 'master' into mo-improvements
Crown421 1978e25
Change supertype, move matrixkernel
Crown421 3ffd436
JuliaFormatter
Crown421 c42e43d
Merge branch 'master' into mo-improvements
Crown421 96bf55e
Remove forced typesymmetry, and improve fallback
Crown421 b649e65
Improve documentation, add matrixkernel to other kernels
Crown421 fe81b0a
Comment out specialized kernelmatrix!
Crown421 509dfd6
Add kernelmatrix! back in with version check
Crown421 33f3e87
Formatter
Crown421 0f9ce64
Improve doc phrasing
Crown421 51a3736
Merge branch 'master' into mo-improvements
Crown421 8459d0c
Change Union name
Crown421 1675598
Substantially improve tests
Crown421 0672a1f
Add ed clarity for lazy kronecker
Crown421 cf8e8f3
Improve tests for lmm and slfm
Crown421 31620e2
Formatter
Crown421 9b27b58
Update src/mokernels/mokernel.jl
Crown421 d68f86e
Remove comments
Crown421 59ff2c8
Add check for lmm kernel, tests
Crown421 7c99633
Merge branch 'mo-improvements' of github.com:Crown421/KernelFunctions…
Crown421 286d5d5
Fix constructor mistake
Crown421 cb37e0f
Remove kwarg dispatch
Crown421 fee8eaf
Remove matrixkernel and lazy kron
Crown421 3466daa
Merge branch 'master' into mo-improvements
Crown421 533f8fd
Remove matrixkernel export
Crown421 213b606
Update src/matrix/kernelkroneckermat.jl
Crown421 f2c6ae6
Update src/mokernels/independent.jl
Crown421 407ca80
Update src/mokernels/independent.jl
Crown421 6bcc83d
Update src/mokernels/mokernel.jl
Crown421 d5571df
helper function name, formatter
Crown421 13427a7
Merge branch 'master' into mo-improvements
Crown421 48db5a0
Remove explicit in-place tests
Crown421 43a5ab9
Remove temp file and bump patch
Crown421 f2ac5ed
Change helper function name
Crown421 dac5db7
Fixed rename oversight
Crown421 e61a668
Fix missing Union
Crown421 8cbb1eb
Silly mistake
Crown421 c72efd9
Make arguments more consistent
Crown421 11e6d56
Forgot to uncomment
Crown421 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
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,79 @@ | ||
# this script should be removed when the alternative MO kernelmatrix is accepted or rejected. | ||
|
||
using KernelFunctions, BenchmarkTools | ||
using LinearAlgebra | ||
|
||
mrank = 1 | ||
dims = (in=5, out=3) | ||
x = [rand(dims.in) for _ in 1:20] | ||
|
||
xMOF = KernelFunctions.MOInputIsotopicByFeatures(x, dims.out) | ||
xMOO = KernelFunctions.MOInputIsotopicByOutputs(x, dims.out) | ||
|
||
indk = IndependentMOKernel(GaussianKernel()) | ||
|
||
Kind1 = kernelmatrix(indk, xMOF, xMOF) | ||
Kind2 = kernelmatrix2(indk, xMOF, xMOF) | ||
|
||
Kind1 ≈ Kind2 | ||
willtebbutt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# true | ||
|
||
@benchmark kernelmatrix($indk, $xMOF, $xMOF) | ||
# BenchmarkTools.Trial: 756 samples with 1 evaluation. | ||
# Range (min … max): 6.186 ms … 11.470 ms ┊ GC (min … max): 0.00% … 35.30% | ||
# Time (median): 6.423 ms ┊ GC (median): 0.00% | ||
# Time (mean ± σ): 6.614 ms ± 806.792 μs ┊ GC (mean ± σ): 2.76% ± 7.77% | ||
|
||
# ▅▇█▇▃ | ||
# ▆██████▅▆▄▅▄▁▄▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▄▁▁▁▁▁▁▁▁▁▁▁▁▁▄▁▁▁▁▁▁▆██▇▇ ▇ | ||
# 6.19 ms Histogram: log(frequency) by time 10 ms < | ||
|
||
# Memory estimate: 2.34 MiB, allocs estimate: 60060. | ||
|
||
@benchmark kernelmatrix2($indk, $xMOF, $xMOF) | ||
# BenchmarkTools.Trial: 10000 samples with 5 evaluations. | ||
# Range (min … max): 6.162 μs … 341.226 μs ┊ GC (min … max): 0.00% … 96.29% | ||
# Time (median): 6.947 μs ┊ GC (median): 0.00% | ||
# Time (mean ± σ): 8.235 μs ± 16.802 μs ┊ GC (mean ± σ): 12.37% ± 5.92% | ||
|
||
# ▁▄▆▇██▇▆▅▄▃▂▁▁▁ ▂ | ||
# ▅██████████████████▇▇▆▇▅▆▆▆▅▅▆▅▅▃▄▅▅▅▁▁▃▁▃▅▅▆▆▆▇▇▇▇▇▇▇██▇▇▇ █ | ||
# 6.16 μs Histogram: log(frequency) by time 13.7 μs < | ||
|
||
# Memory estimate: 34.89 KiB, allocs estimate: 7. | ||
|
||
|
||
A = randn(dims.out, mrank) | ||
B = A * transpose(A) + Diagonal(rand(dims.out)) | ||
|
||
ickernel = IntrinsicCoregionMOKernel(GaussianKernel(), B) | ||
|
||
Kic1 = kernelmatrix(ickernel, xMOF, xMOF) | ||
Kic2 = kernelmatrix2(ickernel, xMOF, xMOF) | ||
|
||
Kic1 ≈ Kic2 | ||
#true | ||
|
||
@benchmark kernelmatrix($ickernel, $xMOF, $xMOF) | ||
# BenchmarkTools.Trial: 1874 samples with 1 evaluation. | ||
# Range (min … max): 2.522 ms … 5.424 ms ┊ GC (min … max): 0.00% … 51.13% | ||
# Time (median): 2.601 ms ┊ GC (median): 0.00% | ||
# Time (mean ± σ): 2.666 ms ± 369.030 μs ┊ GC (mean ± σ): 2.01% ± 7.04% | ||
|
||
# ▂█▆▁ ▁ | ||
# ███████▅▄▅▅▃▁▁▃▅▁▁▁▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▇▇ █ | ||
# 2.52 ms Histogram: log(frequency) by time 570 ms < | ||
|
||
# Memory estimate: 985.47 KiB, allocs estimate: 39639. | ||
|
||
@benchmark kernelmatrix2($ickernel, $xMOF, $xMOF) | ||
# BenchmarkTools.Trial: 10000 samples with 5 evaluations. | ||
# Range (min … max): 6.152 μs … 322.002 μs ┊ GC (min … max): 0.00% … 96.14% | ||
# Time (median): 6.676 μs ┊ GC (median): 0.00% | ||
# Time (mean ± σ): 8.100 μs ± 16.959 μs ┊ GC (mean ± σ): 12.53% ± 5.85% | ||
|
||
# ▄▇██▇▅▄▃▂▁▁ ▁▁▁▁ ▂ | ||
# ▆██████████████▇▇▇▆▆▇▇▇▇▆▇▆▄▅▄▃▆▁▅▄▅▆▆▅▅▄▅▄▆▇▇█▇▇▇▇██████▇▇ █ | ||
# 6.15 μs Histogram: log(frequency) by time 13.5 μs < | ||
|
||
# Memory estimate: 34.77 KiB, allocs estimate: 6. |
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.