pub struct GATConv { /* private fields */ }Expand description
Graph Attention Network layer (Velickovic et al., 2018).
Uses attention mechanism to weight neighbor contributions:
α_ij = softmax_j(LeakyReLU(a^T [W*h_i || W*h_j]))
h_i' = σ(Σ_j α_ij * W * h_j)§Example
ⓘ
use aprender::gnn::GATConv;
let gat = GATConv::new(16, 32, 4); // 16 in → 32 out, 4 attention headsImplementations§
Source§impl GATConv
impl GATConv
Sourcepub fn new(in_features: usize, out_features: usize, num_heads: usize) -> GATConv
pub fn new(in_features: usize, out_features: usize, num_heads: usize) -> GATConv
Create a new GAT convolutional layer.
§Arguments
in_features- Input feature dimensionout_features- Output feature dimension per attention headnum_heads- Number of attention heads
Sourcepub fn out_features(&self) -> usize
pub fn out_features(&self) -> usize
Get output dimension per head.
Sourcepub fn total_out_features(&self) -> usize
pub fn total_out_features(&self) -> usize
Total output dimension (out_features * num_heads).
Trait Implementations§
Source§impl Module for GATConv
impl Module for GATConv
Source§fn parameters_mut(&mut self) -> Vec<&mut Tensor>
fn parameters_mut(&mut self) -> Vec<&mut Tensor>
Get mutable references to all learnable parameters. Read more
Source§fn named_parameters(&self) -> Vec<(String, &Tensor)>
fn named_parameters(&self) -> Vec<(String, &Tensor)>
Get
(name, parameter) pairs for all learnable parameters. Read moreSource§fn named_parameters_mut(&mut self) -> Vec<(String, &mut Tensor)>
fn named_parameters_mut(&mut self) -> Vec<(String, &mut Tensor)>
Get
(name, mutable parameter) pairs for all learnable parameters. Read moreSource§fn set_training(&mut self, training: bool)
fn set_training(&mut self, training: bool)
Set training mode recursively, propagating into child modules. Read more
Source§fn refresh_caches(&mut self)
fn refresh_caches(&mut self)
Refresh any cached computations after parameters have been modified. Read more
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Get the number of learnable parameters.
Auto Trait Implementations§
impl !RefUnwindSafe for GATConv
impl !UnwindSafe for GATConv
impl Freeze for GATConv
impl Send for GATConv
impl Sync for GATConv
impl Unpin for GATConv
impl UnsafeUnpin for GATConv
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