pub struct MultiHeadAttention {
pub w_q: Tensor,
pub w_k: Tensor,
pub w_v: Tensor,
pub w_o: Tensor,
pub num_heads: usize,
pub d_k: usize,
}Expand description
Multi-head attention weights.
Fields§
§w_q: Tensor§w_k: Tensor§w_v: Tensor§w_o: Tensor§num_heads: usize§d_k: usizeImplementations§
Source§impl MultiHeadAttention
impl MultiHeadAttention
Sourcepub fn new(config: &MultiHeadAttentionConfig) -> Result<Self, ModelError>
pub fn new(config: &MultiHeadAttentionConfig) -> Result<Self, ModelError>
Creates zero-initialized multi-head attention weights.
Auto Trait Implementations§
impl Freeze for MultiHeadAttention
impl RefUnwindSafe for MultiHeadAttention
impl Send for MultiHeadAttention
impl Sync for MultiHeadAttention
impl Unpin for MultiHeadAttention
impl UnsafeUnpin for MultiHeadAttention
impl UnwindSafe for MultiHeadAttention
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