pub struct MeanFieldGaussian {
pub means: Array1<f64>,
pub log_stds: Array1<f64>,
pub dim: usize,
}Expand description
Mean-field Gaussian variational family
Approximates the posterior with a factorized Gaussian: q(z) = prod_i N(z_i; mu_i, sigma_i^2)
This is the simplest variational family but cannot capture correlations.
Fields§
§means: Array1<f64>Variational means
log_stds: Array1<f64>Variational log standard deviations (unconstrained parameterization)
dim: usizeDimensionality
Implementations§
Source§impl MeanFieldGaussian
impl MeanFieldGaussian
Sourcepub fn from_params(means: Array1<f64>, log_stds: Array1<f64>) -> Result<Self>
pub fn from_params(means: Array1<f64>, log_stds: Array1<f64>) -> Result<Self>
Create from specific parameters
Sourcepub fn sample(&self, epsilon: &Array1<f64>) -> Result<Array1<f64>>
pub fn sample(&self, epsilon: &Array1<f64>) -> Result<Array1<f64>>
Sample from the variational distribution using reparameterization trick
z = mu + sigma * epsilon, where epsilon ~ N(0, I)
Sourcepub fn entropy(&self) -> f64
pub fn entropy(&self) -> f64
Compute the entropy of the mean-field Gaussian H[q] = sum_i 0.5 * (1 + log(2pi) + 2log_std_i)
Sourcepub fn get_params(&self) -> Array1<f64>
pub fn get_params(&self) -> Array1<f64>
Get all variational parameters as a flat vector
Trait Implementations§
Source§impl Clone for MeanFieldGaussian
impl Clone for MeanFieldGaussian
Source§fn clone(&self) -> MeanFieldGaussian
fn clone(&self) -> MeanFieldGaussian
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MeanFieldGaussian
impl RefUnwindSafe for MeanFieldGaussian
impl Send for MeanFieldGaussian
impl Sync for MeanFieldGaussian
impl Unpin for MeanFieldGaussian
impl UnsafeUnpin for MeanFieldGaussian
impl UnwindSafe for MeanFieldGaussian
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.