pub struct VariationalAutoencoder { /* private fields */ }Expand description
Variational Autoencoder for chess position manifold learning with uncertainty quantification
Implementations§
Source§impl VariationalAutoencoder
impl VariationalAutoencoder
pub fn new(input_dim: usize, latent_dim: usize, beta: f32) -> Self
Sourcepub fn init_network(&mut self, hidden_dims: &[usize]) -> Result<(), String>
pub fn init_network(&mut self, hidden_dims: &[usize]) -> Result<(), String>
Initialize the VAE network with configurable architecture
Sourcepub fn forward(&self, x: &Tensor) -> CandleResult<(Tensor, Tensor, Tensor)>
pub fn forward(&self, x: &Tensor) -> CandleResult<(Tensor, Tensor, Tensor)>
Forward pass through the VAE
Sourcepub fn compute_loss(
&self,
x: &Tensor,
reconstruction: &Tensor,
mean: &Tensor,
logvar: &Tensor,
) -> CandleResult<Tensor>
pub fn compute_loss( &self, x: &Tensor, reconstruction: &Tensor, mean: &Tensor, logvar: &Tensor, ) -> CandleResult<Tensor>
Compute VAE loss (reconstruction + KL divergence)
Sourcepub fn train_step(&mut self, vectors: &Array2<f32>) -> Result<f32, String>
pub fn train_step(&mut self, vectors: &Array2<f32>) -> Result<f32, String>
Train the VAE on a batch of position vectors
Sourcepub fn encode(
&self,
vectors: &Array2<f32>,
) -> Result<(Array2<f32>, Array2<f32>), String>
pub fn encode( &self, vectors: &Array2<f32>, ) -> Result<(Array2<f32>, Array2<f32>), String>
Encode positions to latent space with uncertainty
Sourcepub fn sample_latent(
&self,
mean: &Array2<f32>,
logvar: &Array2<f32>,
) -> Result<Array2<f32>, String>
pub fn sample_latent( &self, mean: &Array2<f32>, logvar: &Array2<f32>, ) -> Result<Array2<f32>, String>
Sample from the latent space
Sourcepub fn decode(
&self,
latent_vectors: &Array2<f32>,
) -> Result<Array2<f32>, String>
pub fn decode( &self, latent_vectors: &Array2<f32>, ) -> Result<Array2<f32>, String>
Decode from latent space
Sourcepub fn encode_with_sampling(
&self,
vectors: &Array2<f32>,
) -> Result<Array2<f32>, String>
pub fn encode_with_sampling( &self, vectors: &Array2<f32>, ) -> Result<Array2<f32>, String>
Full encoding pipeline (encode then sample)
Sourcepub fn generate(&self, num_samples: usize) -> Result<Array2<f32>, String>
pub fn generate(&self, num_samples: usize) -> Result<Array2<f32>, String>
Generate new samples from the learned manifold
Sourcepub fn evaluate_reconstruction(
&self,
vectors: &Array2<f32>,
) -> Result<HashMap<String, f32>, String>
pub fn evaluate_reconstruction( &self, vectors: &Array2<f32>, ) -> Result<HashMap<String, f32>, String>
Get reconstruction quality metrics
Sourcepub fn latent_dim(&self) -> usize
pub fn latent_dim(&self) -> usize
Get the latent dimensionality
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Check if the VAE is initialized
Auto Trait Implementations§
impl Freeze for VariationalAutoencoder
impl !RefUnwindSafe for VariationalAutoencoder
impl Send for VariationalAutoencoder
impl Sync for VariationalAutoencoder
impl Unpin for VariationalAutoencoder
impl !UnwindSafe for VariationalAutoencoder
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