pub struct FullRankGaussian {
pub mean: Array1<f64>,
pub chol_factor: Array2<f64>,
pub dim: usize,
}Expand description
Full-rank Gaussian variational family
Approximates the posterior with a Gaussian with full covariance: q(z) = N(z; mu, Sigma) where Sigma = L L^T (Cholesky parameterization)
This can capture correlations but has O(d^2) parameters.
Fields§
§mean: Array1<f64>Variational mean
chol_factor: Array2<f64>Lower triangular Cholesky factor of the covariance Stored as a flattened lower-triangular matrix
dim: usizeDimensionality
Implementations§
Source§impl FullRankGaussian
impl FullRankGaussian
Sourcepub fn from_params(mean: Array1<f64>, chol_factor: Array2<f64>) -> Result<Self>
pub fn from_params(mean: Array1<f64>, chol_factor: Array2<f64>) -> Result<Self>
Create from specific parameters
Sourcepub fn covariance(&self) -> Array2<f64>
pub fn covariance(&self) -> Array2<f64>
Get the covariance matrix: Sigma = L * L^T
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 + L * epsilon, where epsilon ~ N(0, I)
Sourcepub fn entropy(&self) -> f64
pub fn entropy(&self) -> f64
Compute the entropy of the full-rank Gaussian H[q] = 0.5 * d * (1 + log(2*pi)) + sum_i log(L_ii)
Sourcepub fn get_params(&self) -> Array1<f64>
pub fn get_params(&self) -> Array1<f64>
Get all variational parameters as a flat vector Layout: [mean, lower-triangular elements of L]
Trait Implementations§
Source§impl Clone for FullRankGaussian
impl Clone for FullRankGaussian
Source§fn clone(&self) -> FullRankGaussian
fn clone(&self) -> FullRankGaussian
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 FullRankGaussian
impl RefUnwindSafe for FullRankGaussian
impl Send for FullRankGaussian
impl Sync for FullRankGaussian
impl Unpin for FullRankGaussian
impl UnsafeUnpin for FullRankGaussian
impl UnwindSafe for FullRankGaussian
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.