pub struct RelativePositionalEncoding<F: Float + Debug> { /* private fields */ }
Expand description
Relative positional encoding
Implements a form of relative positional encoding that can capture pairwise positional relationships efficiently.
Implementations§
Trait Implementations§
Source§impl<F: Float + Debug + 'static> PositionalEncoding<F> for RelativePositionalEncoding<F>
impl<F: Float + Debug + 'static> PositionalEncoding<F> for RelativePositionalEncoding<F>
Source§fn forward(&self, embeddings: &Array<F, IxDyn>) -> Result<Array<F, IxDyn>>
fn forward(&self, embeddings: &Array<F, IxDyn>) -> Result<Array<F, IxDyn>>
Apply positional encoding to input embeddings Read more
Source§fn get_encoding(&self, seq_len: usize) -> Result<Array<F, IxDyn>>
fn get_encoding(&self, seq_len: usize) -> Result<Array<F, IxDyn>>
Get the positional encoding matrix directly Read more
Source§fn update(&mut self, learning_rate: F) -> Result<()>
fn update(&mut self, learning_rate: F) -> Result<()>
Update learnable parameters if any Read more
Source§fn set_training(&mut self, _training: bool)
fn set_training(&mut self, _training: bool)
Set training mode (does nothing by default)
Source§fn is_training(&self) -> bool
fn is_training(&self) -> bool
Get training mode (false by default)
Auto Trait Implementations§
impl<F> Freeze for RelativePositionalEncoding<F>
impl<F> RefUnwindSafe for RelativePositionalEncoding<F>where
F: RefUnwindSafe,
impl<F> Send for RelativePositionalEncoding<F>where
F: Send,
impl<F> Sync for RelativePositionalEncoding<F>where
F: Sync,
impl<F> Unpin for RelativePositionalEncoding<F>
impl<F> UnwindSafe for RelativePositionalEncoding<F>where
F: RefUnwindSafe,
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