pub struct TransformerFfn {
pub d_model: usize,
pub d_ff: usize,
pub w1: Vec<f64>,
pub b1: Vec<f64>,
pub w2: Vec<f64>,
pub b2: Vec<f64>,
}Expand description
Position-wise feed-forward network used inside a transformer block.
FFN(x) = max(0, x W1 + b1) W2 + b2
Applied identically to each position in the sequence.
Fields§
§d_model: usizeInput / output dimensionality.
d_ff: usizeInner (hidden) dimensionality.
w1: Vec<f64>W1: [d_ff × d_model]
b1: Vec<f64>b1: [d_ff]
w2: Vec<f64>W2: [d_model × d_ff]
b2: Vec<f64>b2: [d_model]
Implementations§
Trait Implementations§
Source§impl Clone for TransformerFfn
impl Clone for TransformerFfn
Source§fn clone(&self) -> TransformerFfn
fn clone(&self) -> TransformerFfn
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TransformerFfn
impl RefUnwindSafe for TransformerFfn
impl Send for TransformerFfn
impl Sync for TransformerFfn
impl Unpin for TransformerFfn
impl UnsafeUnpin for TransformerFfn
impl UnwindSafe for TransformerFfn
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> 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>
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