pub struct StochasticGraphLayer {
pub n_nodes: usize,
pub n_features: usize,
pub storage: AdjStorage,
pub weights: Vec<f64>,
pub degrees: Vec<f64>,
}Fields§
§n_nodes: usize§n_features: usize§storage: AdjStorage§weights: Vec<f64>§degrees: Vec<f64>Implementations§
Source§impl StochasticGraphLayer
impl StochasticGraphLayer
Sourcepub fn new(
adj_flat: Vec<f64>,
n_nodes: usize,
n_features: usize,
seed: u64,
) -> Self
pub fn new( adj_flat: Vec<f64>, n_nodes: usize, n_features: usize, seed: u64, ) -> Self
Construct from dense adjacency matrix (backwards-compatible API).
Sourcepub fn new_sparse(
csr: CsrMatrix,
n_features: usize,
seed: u64,
) -> Result<Self, String>
pub fn new_sparse( csr: CsrMatrix, n_features: usize, seed: u64, ) -> Result<Self, String>
Construct from pre-built CSR adjacency.
Sourcepub fn from_dense_auto(
adj_flat: Vec<f64>,
n_nodes: usize,
n_features: usize,
seed: u64,
density_threshold: f64,
) -> Self
pub fn from_dense_auto( adj_flat: Vec<f64>, n_nodes: usize, n_features: usize, seed: u64, density_threshold: f64, ) -> Self
Convert dense adjacency to CSR if density < density_threshold (default 0.3).
fn validate_features(&self, node_features: &[f64]) -> Result<(), String>
Sourcefn aggregate_and_transform(&self, agg_flat: &[f64]) -> Vec<f64>
fn aggregate_and_transform(&self, agg_flat: &[f64]) -> Vec<f64>
Aggregate + weight transform + tanh, dispatched on storage.
Sourcepub fn forward(&self, node_features: &[f64]) -> Result<Vec<f64>, String>
pub fn forward(&self, node_features: &[f64]) -> Result<Vec<f64>, String>
Rate-mode graph forward pass.
Sourcepub fn forward_sc(
&self,
node_features: &[f64],
length: usize,
seed: u64,
) -> Result<Vec<f64>, String>
pub fn forward_sc( &self, node_features: &[f64], length: usize, seed: u64, ) -> Result<Vec<f64>, String>
SC-mode forward pass using AND+popcount message passing.
Dense: encodes full adjacency matrix. Sparse: encodes only non-zero CSR entries, avoiding O(n^2) dense expansion.
pub fn get_weights(&self) -> Vec<f64>
pub fn set_weights(&mut self, weights: Vec<f64>) -> Result<(), String>
Auto Trait Implementations§
impl Freeze for StochasticGraphLayer
impl RefUnwindSafe for StochasticGraphLayer
impl Send for StochasticGraphLayer
impl Sync for StochasticGraphLayer
impl Unpin for StochasticGraphLayer
impl UnsafeUnpin for StochasticGraphLayer
impl UnwindSafe for StochasticGraphLayer
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> 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