pub struct EncoderLayerConfig {
pub attention: AttentionConfig,
pub feed_forward: FeedForwardConfig,
pub layer_norm: LayerNormConfig,
pub pre_norm: bool,
}Expand description
Configuration for a complete transformer encoder layer
Fields§
§attention: AttentionConfigAttention configuration
feed_forward: FeedForwardConfigFeed-forward configuration
layer_norm: LayerNormConfigLayer normalization configuration
pre_norm: boolWhether to use pre-layer normalization (vs post)
Implementations§
Source§impl EncoderLayerConfig
impl EncoderLayerConfig
Sourcepub fn new(d_model: usize, n_heads: usize, d_ff: usize) -> Result<Self>
pub fn new(d_model: usize, n_heads: usize, d_ff: usize) -> Result<Self>
Create a new encoder layer configuration
Sourcepub fn with_pre_norm(self, pre_norm: bool) -> Self
pub fn with_pre_norm(self, pre_norm: bool) -> Self
Set pre-normalization vs post-normalization
Sourcepub fn with_causal(self, causal: bool) -> Self
pub fn with_causal(self, causal: bool) -> Self
Set causal masking
Sourcepub fn with_dropout(self, dropout: f64) -> Self
pub fn with_dropout(self, dropout: f64) -> Self
Set dropout
Trait Implementations§
Source§impl Clone for EncoderLayerConfig
impl Clone for EncoderLayerConfig
Source§fn clone(&self) -> EncoderLayerConfig
fn clone(&self) -> EncoderLayerConfig
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 EncoderLayerConfig
impl RefUnwindSafe for EncoderLayerConfig
impl Send for EncoderLayerConfig
impl Sync for EncoderLayerConfig
impl Unpin for EncoderLayerConfig
impl UnsafeUnpin for EncoderLayerConfig
impl UnwindSafe for EncoderLayerConfig
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