Skip to main content

Module deep_kernel

Module deep_kernel 

Source
Expand description

Deep Kernel Learning (DKL).

This module implements the Deep Kernel Learning architecture of Wilson et al. (2016). A DKL wraps a classical base kernel K_base(·, ·) with a differentiable feature extractor g_θ and evaluates

K_DKL(x, y) = K_base(g_θ(x), g_θ(y)).

In the v0.2.0 research preview we ship a single reference feature extractor — an MLP with Xavier/Glorot-normal initialisation (via SciRS2-Core’s seeded RNG) and support for ReLU / Tanh / Identity activations. The generic DeepKernel is parameterised by the extractor and the base kernel, so any other kernel in this crate (RBF, Linear, Matern, …) plugs in without modification.

§Relationship to learned_composition

This module is the “nonlinear feature composition” counterpart of crate::learned_composition. Where crate::learned_composition::LearnedMixtureKernel learns a softmax-weighted mixture over a library of kernels, DeepKernel learns a nonlinear feature map that transforms inputs before a single base kernel is applied. The two modules are intended to be used together for expressive, trainable similarity metrics.

§Module layout

§Gradient semantics

§Example

use tensorlogic_sklears_kernels::{
    deep_kernel::{Activation, DeepKernelBuilder},
    Kernel, RbfKernel, RbfKernelConfig,
};

let rbf = RbfKernel::new(RbfKernelConfig::new(0.5)).expect("valid gamma");
let dkl = DeepKernelBuilder::new()
    .input_dim(2)
    .hidden_layer(4, Activation::Tanh)
    .output_dim(2, Activation::Identity)
    .seed(42)
    .build(rbf)
    .expect("valid topology");

let x = vec![0.1, -0.2];
let y = vec![0.3, 0.4];
let _value = dkl.compute(&x, &y).expect("dkl value");

Re-exports§

pub use builder::DeepKernelBuilder;
pub use feature_extractor::ForwardCache;
pub use feature_extractor::LayerCache;
pub use feature_extractor::MLPFeatureExtractor;
pub use feature_extractor::NeuralFeatureMap;
pub use gradient::finite_difference_gradient;
pub use gradient::rbf_dkl_gradient;
pub use kernel::DeepKernel;
pub use kernel::DeepKernelSummary;
pub use kernel::FeatureMapShape;
pub use layer::Activation;
pub use layer::DenseLayer;

Modules§

builder
Fluent builder for common Deep Kernel topologies.
feature_extractor
Differentiable feature extractors for Deep Kernel Learning.
gradient
Gradient helpers for DeepKernels.
kernel
The DeepKernel type — a Deep Kernel Learning wrapper that composes a base kernel with a neural feature extractor.
layer
Dense layer and element-wise activations for deep kernel feature extractors.