You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often you don't have (or need) a function to compute a kernel matrix on the fly, but you already have a precomputed Gram matrix. Example code how I solved this (because I needed a diffusion kernel):
struct Diffusion <:Kernel
K
functionDiffusion(A::AbstractMatrix, β::Real=1.0; norm=false)
L =laplacian(A)
if norm
L =norm_laplacian(L)
endreturnnew(exp(β * L))
endend#Diffusion(E::Eigen, β::Real=1.0) = Diffusion(diffusion(E, β))ew(k::Diffusion, x::AbstractVector{<:Int}) = [k.K[i,i] for i in x]
ew(k::Diffusion, x::AbstractVector{<:Int}, x′::AbstractVector{<:Int}) = [k.K[i,j] for (i,j) inzip(x, x′)]
pw(k::Diffusion, x::AbstractVector{<:Int}) = k.K[x,x]
pw(k::Diffusion, x::AbstractVector{<:Int}, x′::AbstractVector{<:Int}) = k.K[x,x′]
Maybe we should have PrecomputedKernel type to mediate this?
The text was updated successfully, but these errors were encountered:
Ahh I see. Yeah, a pre-computed kernel makes sense. Would be very happy to receive a PR involving a pre-computed kernel. I don't have a great intuition for what the best construction interface would be, but it might literally just be to pass in a matrix of numbers.
Often you don't have (or need) a function to compute a kernel matrix on the fly, but you already have a precomputed Gram matrix. Example code how I solved this (because I needed a diffusion kernel):
Maybe we should have
PrecomputedKernel
type to mediate this?The text was updated successfully, but these errors were encountered: