-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Proposal 1
# Euclidean domain with D dimensions.
struct Euclidean
D::Int
end
dim(domain::Euclidean) = domain.D
"""
DomainKernel{Tkernel<:Kernel, Tdomain}
A kernel with additional information specifying the domain of the kernel.
This provides a complete specification of a kernel, whereas most kernels by themselves do
not provide the domain information necessary to construct e.g. Random Fourier Feature
approximations to themselves.
"""
struct DomainKernel{Tkernel<:Kernel, Tdomain} <: Kernel
kernel::Tkernel
domain::Tdomain
end
kernelmatrix(k::DomainKernel, x::AbstractVector) = kernelmatrix(k.kernel, x)
function kernelmatrix(k::DomainKernel, x::AbstractVector, x′::AbstractVector)
return kernelmatrix(k.kernel, x, x′)
endProposal 2
struct AutoEuclidean end
struct Euclidean
D::Int
end
struct SEKernel{Tmetric_space} <: Kernel
metric_space::Tmetric_space
end
SEKernel() = SEKernel(AutoEuclidean())This version would be quite breaking, but I'd rather we didn't worry about that, and instead focus on which one we think constitutes the better solution, and go from there.
I'm personally leaning more towards the second option -- it feel cleaner on some level. The DomainKernel idea would probably work, but my gut is that it'll be messy in practice. You would have to write
DomainKernel(SEKernel(), Euclidean(5)) + 0.5 * with_lengthscale(DomainKernel(SEKernel(), Euclidean(5)))vs
SEKernel(Euclidean(5)) + 0.5 * with_lengthscale(SEKernel(Euclidean(5)))My feeling is that the latter is easier to read.
It also avoid some redundancy -- we currently let users specify the metric in a lot of kernels. Having the metric and domain of the kernel specified in different places feels strange to me.
Metadata
Metadata
Assignees
Labels
No labels