pub struct GraphSageLayer {
pub weights: Array2<f64>,
pub bias: Option<Array1<f64>>,
pub in_dim: usize,
pub out_dim: usize,
pub aggregation: SageAggregation,
pub use_relu: bool,
pub normalize: bool,
}Expand description
A single GraphSAGE layer.
Concatenates each node’s own representation with the aggregated neighbor representation, then applies a linear transformation:
h_v = σ( W · concat(h_v, AGG({h_u : u ∈ N(v)})) + b )The output is L2-normalized (per-node) following the original paper.
Fields§
§weights: Array2<f64>Weight matrix [2 * in_dim, out_dim]
bias: Option<Array1<f64>>Optional bias [out_dim]
in_dim: usizeInput feature dimension
out_dim: usizeOutput feature dimension
aggregation: SageAggregationAggregation strategy
use_relu: boolApply ReLU activation
normalize: boolApply L2 normalization on output embeddings
Implementations§
Source§impl GraphSageLayer
impl GraphSageLayer
Sourcepub fn new(in_dim: usize, out_dim: usize) -> Self
pub fn new(in_dim: usize, out_dim: usize) -> Self
Create a new GraphSAGE layer with Glorot-uniform initialization.
§Arguments
in_dim– Input feature dimension per node.out_dim– Output embedding dimension.
Sourcepub fn with_aggregation(self, aggr: SageAggregation) -> Self
pub fn with_aggregation(self, aggr: SageAggregation) -> Self
Use a specific aggregation strategy.
Sourcepub fn without_normalize(self) -> Self
pub fn without_normalize(self) -> Self
Disable L2 normalization on output.
Sourcepub fn without_activation(self) -> Self
pub fn without_activation(self) -> Self
Disable ReLU activation.
Trait Implementations§
Source§impl Clone for GraphSageLayer
impl Clone for GraphSageLayer
Source§fn clone(&self) -> GraphSageLayer
fn clone(&self) -> GraphSageLayer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for GraphSageLayer
impl RefUnwindSafe for GraphSageLayer
impl Send for GraphSageLayer
impl Sync for GraphSageLayer
impl Unpin for GraphSageLayer
impl UnsafeUnpin for GraphSageLayer
impl UnwindSafe for GraphSageLayer
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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