JuliaGaussianProcesses / JuliaGaussianProcesses/KernelFunctions.jl

Specifying Domain of Kernels

Open
#382 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
275
Forks
41
PR merge metrics
No merged PRs in 30d

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′)
end

Proposal 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing Proposal 1 and Proposal 2 with the existing kernel constructors and the current places where kernels accept a metric. Trace how domain information is needed for kernel operations and Random Fourier Feature construction. Done means the project has an agreed domain-specification design and the affected kernel interfaces consistently follow it.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.