pub struct DeepKernel<F: NeuralFeatureMap, K: Kernel> { /* private fields */ }Expand description
Composition of a neural feature extractor with a classical kernel.
F — the neural feature extractor (e.g.
crate::deep_kernel::MLPFeatureExtractor).
K — the base kernel (e.g. crate::RbfKernel).
Implementations§
Source§impl<F: NeuralFeatureMap, K: Kernel> DeepKernel<F, K>
impl<F: NeuralFeatureMap, K: Kernel> DeepKernel<F, K>
Sourcepub fn feature_extractor(&self) -> &F
pub fn feature_extractor(&self) -> &F
Immutable view of the feature extractor.
Sourcepub fn feature_extractor_mut(&mut self) -> &mut F
pub fn feature_extractor_mut(&mut self) -> &mut F
Mutable view of the feature extractor — needed by optimisers
that write into parameters_mut() and then call sync_from_flat
on a concrete MLP.
Sourcepub fn base_kernel(&self) -> &K
pub fn base_kernel(&self) -> &K
Immutable view of the base kernel.
Sourcepub fn evaluate(&self, x: &[f64], y: &[f64]) -> Result<f64>
pub fn evaluate(&self, x: &[f64], y: &[f64]) -> Result<f64>
Evaluate the composed kernel on a single input pair.
Sourcepub fn compute_gram(
&self,
xs: &[&[f64]],
ys: &[&[f64]],
) -> Result<Vec<Vec<f64>>>
pub fn compute_gram( &self, xs: &[&[f64]], ys: &[&[f64]], ) -> Result<Vec<Vec<f64>>>
Compute a Gram matrix G[i,j] = K_DKL(xs[i], ys[j]).
Feature maps are cached — each xs[i] is passed through the
extractor at most once, same for ys[j]. For square xs == ys
callers should prefer Self::compute_symmetric_gram.
Trait Implementations§
Source§impl<F: Clone + NeuralFeatureMap, K: Clone + Kernel> Clone for DeepKernel<F, K>
impl<F: Clone + NeuralFeatureMap, K: Clone + Kernel> Clone for DeepKernel<F, K>
Source§fn clone(&self) -> DeepKernel<F, K>
fn clone(&self) -> DeepKernel<F, K>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug + NeuralFeatureMap, K: Debug + Kernel> Debug for DeepKernel<F, K>
impl<F: Debug + NeuralFeatureMap, K: Debug + Kernel> Debug for DeepKernel<F, K>
Auto Trait Implementations§
impl<F, K> Freeze for DeepKernel<F, K>
impl<F, K> RefUnwindSafe for DeepKernel<F, K>where
F: RefUnwindSafe,
K: RefUnwindSafe,
impl<F, K> Send for DeepKernel<F, K>
impl<F, K> Sync for DeepKernel<F, K>
impl<F, K> Unpin for DeepKernel<F, K>
impl<F, K> UnsafeUnpin for DeepKernel<F, K>where
F: UnsafeUnpin,
K: UnsafeUnpin,
impl<F, K> UnwindSafe for DeepKernel<F, K>where
F: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more