pub struct GraphGAN { /* private fields */ }Expand description
Graph Generative Adversarial Network (GraphGAN) Learns to generate realistic graphs through adversarial training
Implementations§
Source§impl GraphGAN
impl GraphGAN
Sourcepub fn new(
latent_dim: usize,
hidden_dim: usize,
output_features: usize,
use_bias: bool,
) -> Result<Self, TorshError>
pub fn new( latent_dim: usize, hidden_dim: usize, output_features: usize, use_bias: bool, ) -> Result<Self, TorshError>
Create a new Graph GAN
Sourcepub fn generate(&self, num_nodes: usize) -> Result<GraphData, TorshError>
pub fn generate(&self, num_nodes: usize) -> Result<GraphData, TorshError>
Generate fake graph from random noise
Sourcepub fn discriminate(&self, graph: &GraphData) -> Result<f32, TorshError>
pub fn discriminate(&self, graph: &GraphData) -> Result<f32, TorshError>
Discriminator forward pass (returns real/fake probability in (0, 1))
§Errors
Propagates discriminator tensor-operation failures.
Sourcepub fn discriminate_logit(&self, graph: &GraphData) -> Result<f32, TorshError>
pub fn discriminate_logit(&self, graph: &GraphData) -> Result<f32, TorshError>
Discriminator forward pass returning the raw pre-sigmoid logit.
The losses are computed from this value rather than from the sigmoid
output: in f32 the sigmoid saturates to exactly 0.0 or 1.0 for
logits beyond roughly +-17, and ln(0) would make the loss infinite.
§Errors
Propagates discriminator tensor-operation failures.
Sourcepub fn generator_loss(&self, num_nodes: usize) -> Result<f32, TorshError>
pub fn generator_loss(&self, num_nodes: usize) -> Result<f32, TorshError>
Train generator (maximize discriminator error)
Computes -log D(G(z)) as softplus(-logit), which is finite for every
finite logit.
§Errors
Propagates generator/discriminator tensor-operation failures.
Sourcepub fn discriminator_loss(
&self,
real_graph: &GraphData,
num_nodes: usize,
) -> Result<f32, TorshError>
pub fn discriminator_loss( &self, real_graph: &GraphData, num_nodes: usize, ) -> Result<f32, TorshError>
Train discriminator (distinguish real from fake)
Computes -log D(real) - log(1 - D(fake)) in the numerically stable
binary-cross-entropy-with-logits form
softplus(-logit_real) + softplus(logit_fake).
§Errors
Propagates generator/discriminator tensor-operation failures.
Sourcepub fn generator_parameters(&self) -> Vec<Tensor>
pub fn generator_parameters(&self) -> Vec<Tensor>
Get generator parameters
Sourcepub fn discriminator_parameters(&self) -> Vec<Tensor>
pub fn discriminator_parameters(&self) -> Vec<Tensor>
Get discriminator parameters
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GraphGAN
impl RefUnwindSafe for GraphGAN
impl Send for GraphGAN
impl Sync for GraphGAN
impl Unpin for GraphGAN
impl UnsafeUnpin for GraphGAN
impl UnwindSafe for GraphGAN
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
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> ⓘ
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> ⓘ
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