Struct friedrich::kernel::SquaredExp
source · Expand description
Squared exponential kernel
Equivalent to a gaussian kernel.
k(x,y) = A exp(-||x-y||² / 2l²)
Where A is the amplitude and l the length scale.
Fields§
§ls: f64
The length scale of the kernel.
ampl: f64
The amplitude of the kernel.
Implementations§
source§impl SquaredExp
impl SquaredExp
sourcepub fn new(ls: f64, ampl: f64) -> SquaredExp
pub fn new(ls: f64, ampl: f64) -> SquaredExp
Construct a new squared exponential kernel (gaussian).
Trait Implementations§
source§impl Clone for SquaredExp
impl Clone for SquaredExp
source§fn clone(&self) -> SquaredExp
fn clone(&self) -> SquaredExp
Returns a copy 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 SquaredExp
impl Debug for SquaredExp
source§impl Default for SquaredExp
impl Default for SquaredExp
Constructs the default Squared Exp kernel.
The defaults are:
- ls = 1
- ampl = 1
source§fn default() -> SquaredExp
fn default() -> SquaredExp
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for SquaredExp
impl<'de> Deserialize<'de> for SquaredExp
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Kernel for SquaredExp
impl Kernel for SquaredExp
source§fn kernel<S1: Storage<f64, U1, Dynamic>, S2: Storage<f64, U1, Dynamic>>(
&self,
x1: &SRowVector<S1>,
x2: &SRowVector<S2>
) -> f64
fn kernel<S1: Storage<f64, U1, Dynamic>, S2: Storage<f64, U1, Dynamic>>(
&self,
x1: &SRowVector<S1>,
x2: &SRowVector<S2>
) -> f64
The squared exponential kernel function.
source§fn nb_parameters(&self) -> usize
fn nb_parameters(&self) -> usize
Numbers of parameters (such as bandwidth and amplitude) of the kernel. Read more
source§fn is_scalable(&self) -> bool
fn is_scalable(&self) -> bool
source§fn gradient<S1: Storage<f64, U1, Dynamic>, S2: Storage<f64, U1, Dynamic>>(
&self,
x1: &SRowVector<S1>,
x2: &SRowVector<S2>
) -> Vec<f64>
fn gradient<S1: Storage<f64, U1, Dynamic>, S2: Storage<f64, U1, Dynamic>>(
&self,
x1: &SRowVector<S1>,
x2: &SRowVector<S2>
) -> Vec<f64>
Takes two equal length slices (row vector) and returns a vector containing the value of the gradient for each parameter in an arbitrary order. Read more
source§fn rescale(&mut self, scale: f64)
fn rescale(&mut self, scale: f64)
Multiplies the amplitude of the kernel by the
scale
parameter such that a kernel a*K(x,y)
becomes scale*a*K(x,y)
. Read moresource§fn get_parameters(&self) -> Vec<f64>
fn get_parameters(&self) -> Vec<f64>
Returns a vector containing all the parameters of the kernel in the same order as the outputs of the
gradient
function.source§fn set_parameters(&mut self, parameters: &[f64])
fn set_parameters(&mut self, parameters: &[f64])
Sets all the parameters of the kernel by reading them from a slice where they are in the same order as the outputs of the
gradient
function.source§fn heuristic_fit<SM: Storage<f64, Dynamic, Dynamic>, SV: Storage<f64, Dynamic, U1>>(
&mut self,
training_inputs: &SMatrix<SM>,
training_outputs: &SVector<SV>
)
fn heuristic_fit<SM: Storage<f64, Dynamic, Dynamic>, SV: Storage<f64, Dynamic, U1>>(
&mut self,
training_inputs: &SMatrix<SM>,
training_outputs: &SVector<SV>
)
Optional, function that fits the kernel parameters on the training data using fast heuristics.
This is used as a starting point for gradient descent. Read more
source§impl Serialize for SquaredExp
impl Serialize for SquaredExp
impl Copy for SquaredExp
Auto Trait Implementations§
impl RefUnwindSafe for SquaredExp
impl Send for SquaredExp
impl Sync for SquaredExp
impl Unpin for SquaredExp
impl UnwindSafe for SquaredExp
Blanket Implementations§
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.