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
layer—DenseLayer/Activationprimitives.feature_extractor—NeuralFeatureMaptrait andMLPFeatureExtractorreference implementation.kernel— theDeepKernelwrapper that composes a feature map with a base kernel and implementscrate::Kernel.gradient— finite-difference verification and an analytical gradient path for the RBF-base case.builder— fluentDeepKernelBuilderfor common MLP topologies.
§Gradient semantics
- Analytical: the closed form
∂K_DKL/∂θfor the MLP-extractor + RBF-base case is available viagradient::rbf_dkl_gradient— one forward+backward pass, no autodiff. - Numerical: every
DeepKernel<MLPFeatureExtractor, K>supportsgradient::finite_difference_gradientas a correctness check or as a stand-in for base kernels whose analytical chain rule has not yet been derived. - Base-kernel hyperparameters: gradients w.r.t. e.g. the RBF
γare not produced here — callers should go throughcrate::tensor_kernels::RbfKernel::compute_with_gradientor a future autodiff layer.
§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
DeepKerneltype — 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.