pub struct GraphSageEncoder { /* private fields */ }Expand description
GraphSAGE encoder.
Implementations§
Source§impl GraphSageEncoder
impl GraphSageEncoder
Sourcepub fn new(config: &GraphSageConfig) -> GnnResult<Self>
pub fn new(config: &GraphSageConfig) -> GnnResult<Self>
Create a new encoder with seed 42.
Sourcepub fn new_with_seed(config: &GraphSageConfig, seed: u64) -> GnnResult<Self>
pub fn new_with_seed(config: &GraphSageConfig, seed: u64) -> GnnResult<Self>
Create a new encoder with an explicit seed for reproducibility.
Sourcepub fn encode(&self, graph: &KgGraph) -> GnnResult<EntityEmbeddings>
pub fn encode(&self, graph: &KgGraph) -> GnnResult<EntityEmbeddings>
Encode all nodes in graph and return entity embeddings.
A fresh RNG derived from the stored seed is created on each call, so repeated calls on the same encoder produce identical results.
Sourcepub fn train(
&mut self,
graph: &KgGraph,
num_epochs: usize,
) -> GnnResult<TrainingHistory>
pub fn train( &mut self, graph: &KgGraph, num_epochs: usize, ) -> GnnResult<TrainingHistory>
Train the encoder for num_epochs using link-prediction loss.
Sourcepub fn compute_grad_and_param_for_test(&mut self, graph: &KgGraph) -> (f64, f64)
pub fn compute_grad_and_param_for_test(&mut self, graph: &KgGraph) -> (f64, f64)
Return (analytic_grad_of_W1[0][0], W1[0][0]) for a fixed triple
(0 → 1) as positive pair. Intended for finite-difference checks.
Sourcepub fn compute_loss_with_perturb(&mut self, graph: &KgGraph, eps: f64) -> f64
pub fn compute_loss_with_perturb(&mut self, graph: &KgGraph, eps: f64) -> f64
Compute loss with W1[0][0] perturbed by eps, then restore.
Uses the same RNG seed as compute_grad_and_param_for_test.
Auto Trait Implementations§
impl Freeze for GraphSageEncoder
impl RefUnwindSafe for GraphSageEncoder
impl Send for GraphSageEncoder
impl Sync for GraphSageEncoder
impl Unpin for GraphSageEncoder
impl UnsafeUnpin for GraphSageEncoder
impl UnwindSafe for GraphSageEncoder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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