pub struct MemoryModule {
pub memory: Array2<f64>,
pub last_update: Vec<f64>,
pub memory_dim: usize,
pub time_dim: usize,
pub n_nodes: usize,
pub update_method: MemoryUpdateMethod,
pub time_encoding: TimeEncoding,
pub message_dim: usize,
/* private fields */
}Expand description
TGN-style memory module that maintains compressed node interaction history.
Each node has a memory vector that is updated when new events arrive. The memory captures temporal patterns and interaction history.
Fields§
§memory: Array2<f64>Node memory states: [n_nodes, memory_dim]
last_update: Vec<f64>Last update timestamp per node
memory_dim: usizeMemory dimension
time_dim: usizeTime encoding dimension
n_nodes: usizeNumber of nodes
update_method: MemoryUpdateMethodMemory update method
time_encoding: TimeEncodingTime encoding module
message_dim: usizeMessage dimension (memory_dim + memory_dim + time_dim + optional features)
Implementations§
Source§impl MemoryModule
impl MemoryModule
Sourcepub fn new(
n_nodes: usize,
memory_dim: usize,
time_dim: usize,
update_method: MemoryUpdateMethod,
) -> Self
pub fn new( n_nodes: usize, memory_dim: usize, time_dim: usize, update_method: MemoryUpdateMethod, ) -> Self
Create a new memory module.
§Arguments
n_nodes- Number of nodes in the graphmemory_dim- Dimension of node memory vectorstime_dim- Dimension for time encodingupdate_method- Memory update method (GRU or MLP)
Sourcepub fn process_event(&mut self, event: &TemporalEvent) -> Result<()>
pub fn process_event(&mut self, event: &TemporalEvent) -> Result<()>
Process a single temporal event and update node memories.
Updates the memory of both source and target nodes involved in the event.
§Arguments
event- The temporal interaction event
Sourcepub fn process_events(&mut self, events: &[TemporalEvent]) -> Result<()>
pub fn process_events(&mut self, events: &[TemporalEvent]) -> Result<()>
Process a batch of temporal events in chronological order.
Events should be sorted by timestamp (ascending).
Sourcepub fn get_memory(&self) -> &Array2<f64>
pub fn get_memory(&self) -> &Array2<f64>
Get the current memory state for all nodes.
Trait Implementations§
Source§impl Clone for MemoryModule
impl Clone for MemoryModule
Source§fn clone(&self) -> MemoryModule
fn clone(&self) -> MemoryModule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MemoryModule
impl RefUnwindSafe for MemoryModule
impl Send for MemoryModule
impl Sync for MemoryModule
impl Unpin for MemoryModule
impl UnsafeUnpin for MemoryModule
impl UnwindSafe for MemoryModule
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
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>
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