pub struct LogNormalVI {
pub dim: usize,
pub mu: Array1<f64>,
pub log_sigma: Array1<f64>,
}Expand description
Variational family using a log-normal distribution for positive-valued variables
z ~ LogNormal(mu, sigma^2), so log(z) ~ N(mu, sigma^2). This is suitable as a variational family for positive-valued latent variables.
Parameters (stored in flat form): [mu_0, …, mu_{d-1}, log_sigma_0, …, log_sigma_{d-1}]
Reparameterization: z_i = exp(mu_i + sigma_i * epsilon_i)
Fields§
§dim: usizeDimension of the latent variable
mu: Array1<f64>Mean parameters of log z: mu_i
log_sigma: Array1<f64>Log standard deviation parameters: log_sigma_i (sigma_i = exp(log_sigma_i))
Implementations§
Source§impl LogNormalVI
impl LogNormalVI
Sourcepub fn new(dim: usize) -> Result<Self>
pub fn new(dim: usize) -> Result<Self>
Create a new LogNormal variational family
Initializes with mu=0 and log_sigma=0 (sigma=1, so lognormal(0,1)).
Sourcepub fn from_params(mu: Array1<f64>, log_sigma: Array1<f64>) -> Result<Self>
pub fn from_params(mu: Array1<f64>, log_sigma: Array1<f64>) -> Result<Self>
Create from explicit parameters
Sourcepub fn means(&self) -> Array1<f64>
pub fn means(&self) -> Array1<f64>
Compute the log-normal mean: E[z_i] = exp(mu_i + sigma_i^2 / 2)
Trait Implementations§
Source§impl Clone for LogNormalVI
impl Clone for LogNormalVI
Source§fn clone(&self) -> LogNormalVI
fn clone(&self) -> LogNormalVI
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 moreSource§impl Debug for LogNormalVI
impl Debug for LogNormalVI
Source§impl VariationalFamily for LogNormalVI
impl VariationalFamily for LogNormalVI
Source§fn get_params(&self) -> Array1<f64>
fn get_params(&self) -> Array1<f64>
Get current variational parameters as a flat vector
Source§fn set_params(&mut self, params: &Array1<f64>) -> Result<()>
fn set_params(&mut self, params: &Array1<f64>) -> Result<()>
Set variational parameters from a flat vector
Source§fn sample_reparam(&self, epsilon: &Array1<f64>) -> Result<(Array1<f64>, f64)>
fn sample_reparam(&self, epsilon: &Array1<f64>) -> Result<(Array1<f64>, f64)>
Sample using the reparameterization trick:
z = f(epsilon; phi), where epsilon ~ base_noise_distribution Read more
Auto Trait Implementations§
impl Freeze for LogNormalVI
impl RefUnwindSafe for LogNormalVI
impl Send for LogNormalVI
impl Sync for LogNormalVI
impl Unpin for LogNormalVI
impl UnsafeUnpin for LogNormalVI
impl UnwindSafe for LogNormalVI
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.