pub struct GraphVAE { /* private fields */ }Expand description
Graph Variational Autoencoder (GraphVAE) Learns a probabilistic latent representation of graphs
Implementations§
Source§impl GraphVAE
impl GraphVAE
Sourcepub fn new(
in_features: usize,
hidden_features: usize,
latent_dim: usize,
beta: f32,
use_bias: bool,
) -> Result<Self, TorshError>
pub fn new( in_features: usize, hidden_features: usize, latent_dim: usize, beta: f32, use_bias: bool, ) -> Result<Self, TorshError>
Create a new Graph Variational Autoencoder
Sourcepub fn encode(&self, graph: &GraphData) -> Result<(Tensor, Tensor), TorshError>
pub fn encode(&self, graph: &GraphData) -> Result<(Tensor, Tensor), TorshError>
Encode graph to latent distribution parameters
Sourcepub fn reparameterize(
&self,
mu: &Tensor,
logvar: &Tensor,
) -> Result<Tensor, TorshError>
pub fn reparameterize( &self, mu: &Tensor, logvar: &Tensor, ) -> Result<Tensor, TorshError>
Reparameterization trick for sampling from latent distribution
Sourcepub fn decode(
&self,
z: &Tensor,
num_nodes: usize,
) -> Result<GraphData, TorshError>
pub fn decode( &self, z: &Tensor, num_nodes: usize, ) -> Result<GraphData, TorshError>
Decode latent representation to graph
Sourcepub fn forward(
&self,
graph: &GraphData,
) -> Result<(GraphData, Tensor, Tensor), TorshError>
pub fn forward( &self, graph: &GraphData, ) -> Result<(GraphData, Tensor, Tensor), TorshError>
Sourcepub fn compute_loss(
&self,
graph: &GraphData,
reconstructed: &GraphData,
mu: &Tensor,
logvar: &Tensor,
) -> Result<f32, TorshError>
pub fn compute_loss( &self, graph: &GraphData, reconstructed: &GraphData, mu: &Tensor, logvar: &Tensor, ) -> Result<f32, TorshError>
Compute VAE loss (reconstruction + KL divergence)
Sourcepub fn generate(&self, num_nodes: usize) -> Result<GraphData, TorshError>
pub fn generate(&self, num_nodes: usize) -> Result<GraphData, TorshError>
Generate new graph from random latent vector
Sourcepub fn interpolate(
&self,
graph1: &GraphData,
graph2: &GraphData,
alpha: f32,
num_nodes: usize,
) -> Result<GraphData, TorshError>
pub fn interpolate( &self, graph1: &GraphData, graph2: &GraphData, alpha: f32, num_nodes: usize, ) -> Result<GraphData, TorshError>
Interpolate between two graphs in latent space
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GraphVAE
impl RefUnwindSafe for GraphVAE
impl Send for GraphVAE
impl Sync for GraphVAE
impl Unpin for GraphVAE
impl UnsafeUnpin for GraphVAE
impl UnwindSafe for GraphVAE
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