pub struct VariationalInference;Expand description
Entry-point for black-box mean-field variational inference.
Implementations§
Source§impl VariationalInference
impl VariationalInference
Sourcepub fn fit(
log_prob: impl Fn(&[f64]) -> f64,
dim: usize,
config: VariationalConfig,
) -> TlBackendResult<MeanFieldGaussian>
pub fn fit( log_prob: impl Fn(&[f64]) -> f64, dim: usize, config: VariationalConfig, ) -> TlBackendResult<MeanFieldGaussian>
Fit a mean-field Gaussian posterior q(z) to the log-joint log_prob.
§Arguments
log_prob— evaluates log p(z) at a given z (up to a constant)dim— number of latent dimensionsconfig— algorithm hyper-parameters
§Algorithm
Uses Adam (β₁=0.9, β₂=0.999, ε=1e-8) to maximise the ELBO. Gradients of the expected log-joint are estimated by the reparameterisation trick with central finite differences (h=1e-5) for ∂log_p/∂z.
§Errors
Returns an error if dim == 0.
Auto Trait Implementations§
impl Freeze for VariationalInference
impl RefUnwindSafe for VariationalInference
impl Send for VariationalInference
impl Sync for VariationalInference
impl Unpin for VariationalInference
impl UnsafeUnpin for VariationalInference
impl UnwindSafe for VariationalInference
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> 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