pub struct TrainableKernelMixture { /* private fields */ }Expand description
Trainable adapter around a LearnedMixtureKernel.
Implementations§
Source§impl TrainableKernelMixture
impl TrainableKernelMixture
Sourcepub fn new(inner: LearnedMixtureKernel) -> Self
pub fn new(inner: LearnedMixtureKernel) -> Self
Wrap an existing mixture kernel.
Sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Number of trainable logits.
Sourcepub fn parameters(&self) -> &[f64]
pub fn parameters(&self) -> &[f64]
Borrow the trainable parameters (logits).
Sourcepub fn evaluate(&self, x: &[f64], y: &[f64]) -> Result<f64>
pub fn evaluate(&self, x: &[f64], y: &[f64]) -> Result<f64>
Forward pass — mixture kernel value.
Sourcepub fn evaluate_with_gradient(
&self,
x: &[f64],
y: &[f64],
) -> Result<(f64, Vec<f64>)>
pub fn evaluate_with_gradient( &self, x: &[f64], y: &[f64], ) -> Result<(f64, Vec<f64>)>
Forward + gradient in a single pass.
Sourcepub fn gradient(&self, x: &[f64], y: &[f64]) -> Result<Vec<f64>>
pub fn gradient(&self, x: &[f64], y: &[f64]) -> Result<Vec<f64>>
Pure gradient (no forward re-use).
Sourcepub fn step(&mut self, gradient: &[f64], learning_rate: f64) -> Result<()>
pub fn step(&mut self, gradient: &[f64], learning_rate: f64) -> Result<()>
Apply a vanilla gradient-descent step w <- w - lr * g.
Sourcepub fn set_parameters(&mut self, new_logits: Vec<f64>) -> Result<()>
pub fn set_parameters(&mut self, new_logits: Vec<f64>) -> Result<()>
Replace the logits outright (useful for optimizer-driven updates).
Sourcepub fn inner(&self) -> &LearnedMixtureKernel
pub fn inner(&self) -> &LearnedMixtureKernel
Borrow the underlying mixture kernel (read-only).
Sourcepub fn into_inner(self) -> LearnedMixtureKernel
pub fn into_inner(self) -> LearnedMixtureKernel
Consume the adapter and return the underlying mixture kernel.
Trait Implementations§
Source§impl Clone for TrainableKernelMixture
impl Clone for TrainableKernelMixture
Source§fn clone(&self) -> TrainableKernelMixture
fn clone(&self) -> TrainableKernelMixture
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 Debug for TrainableKernelMixture
impl Debug for TrainableKernelMixture
Source§impl From<LearnedMixtureKernel> for TrainableKernelMixture
impl From<LearnedMixtureKernel> for TrainableKernelMixture
Source§fn from(inner: LearnedMixtureKernel) -> Self
fn from(inner: LearnedMixtureKernel) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TrainableKernelMixture
impl !RefUnwindSafe for TrainableKernelMixture
impl Send for TrainableKernelMixture
impl Sync for TrainableKernelMixture
impl Unpin for TrainableKernelMixture
impl UnsafeUnpin for TrainableKernelMixture
impl !UnwindSafe for TrainableKernelMixture
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