pub struct ContinuousNormalizingFlow {
pub dynamics: CnfDynamics,
pub base_mean: Vec<f64>,
pub base_std: Vec<f64>,
}Expand description
Continuous Normalizing Flow model.
Transforms a base distribution p_0 = N(base_mean, diag(base_std^2)) into
a target distribution via the ODE dz/dt = f(z, t; θ).
Log-likelihood computation:
log p(x) = log p_0(z_0) + ∫_0^T tr(∂f/∂z) dtFields§
§dynamics: CnfDynamicsODE dynamics network.
base_mean: Vec<f64>Mean of the base Gaussian distribution.
base_std: Vec<f64>Standard deviation of the base Gaussian distribution (diagonal).
Implementations§
Source§impl ContinuousNormalizingFlow
impl ContinuousNormalizingFlow
Sourcepub fn new(z_dim: usize, hidden_dim: usize, n_layers: usize) -> Self
pub fn new(z_dim: usize, hidden_dim: usize, n_layers: usize) -> Self
Create a CNF with standard-normal base distribution.
Sourcepub fn integrate_forward(
&self,
z0: &[f64],
n_steps: usize,
t_start: f64,
t_end: f64,
) -> (Vec<f64>, f64)
pub fn integrate_forward( &self, z0: &[f64], n_steps: usize, t_start: f64, t_end: f64, ) -> (Vec<f64>, f64)
Euler-integrate the augmented ODE (dz/dt, d_logdet/dt) from t_start to t_end.
Returns (z_T, log_det_jacobian) where log_det_jacobian = ∫ tr(∂f/∂z) dt.
Sourcepub fn integrate_backward(&self, x: &[f64], n_steps: usize) -> (Vec<f64>, f64)
pub fn integrate_backward(&self, x: &[f64], n_steps: usize) -> (Vec<f64>, f64)
Euler-integrate backwards from T=1 to T=0 (inverse direction).
Returns (z_0, log_det) where log_det = -∫_T^0 tr(∂f/∂z) dt.
Sourcepub fn log_prob(&self, x: &[f64], n_steps: usize) -> f64
pub fn log_prob(&self, x: &[f64], n_steps: usize) -> f64
Compute log p(x) = log p_0(z_0) + log_det via backward integration.
Auto Trait Implementations§
impl Freeze for ContinuousNormalizingFlow
impl RefUnwindSafe for ContinuousNormalizingFlow
impl Send for ContinuousNormalizingFlow
impl Sync for ContinuousNormalizingFlow
impl Unpin for ContinuousNormalizingFlow
impl UnsafeUnpin for ContinuousNormalizingFlow
impl UnwindSafe for ContinuousNormalizingFlow
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
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 more