Struct burn_core::nn::transformer::TransformerEncoderConfig
source · pub struct TransformerEncoderConfig {
pub d_model: usize,
pub d_ff: usize,
pub n_heads: usize,
pub n_layers: usize,
pub dropout: f64,
pub norm_first: bool,
pub initializer: Initializer,
}Expand description
Configuration to create a Transformer Encoder layer.
Fields§
§d_model: usizeThe size of the model.
d_ff: usizeThe size of the position-wise feed-forward network.
n_heads: usizeThe number of attention heads.
n_layers: usizeThe number of layers.
dropout: f64The dropout rate. Default: 0.1
norm_first: boolLayer norm will be applied first instead of after the other modules.
initializer: InitializerThe type of function used to initialize neural network parameters
Implementations§
source§impl TransformerEncoderConfig
impl TransformerEncoderConfig
sourcepub fn with_dropout(self, dropout: f64) -> Self
pub fn with_dropout(self, dropout: f64) -> Self
The dropout rate. Default: 0.1
sourcepub fn with_norm_first(self, norm_first: bool) -> Self
pub fn with_norm_first(self, norm_first: bool) -> Self
Layer norm will be applied first instead of after the other modules.
sourcepub fn with_initializer(self, initializer: Initializer) -> Self
pub fn with_initializer(self, initializer: Initializer) -> Self
The type of function used to initialize neural network parameters
source§impl TransformerEncoderConfig
impl TransformerEncoderConfig
sourcepub fn init<B: Backend>(&self) -> TransformerEncoder<B>
pub fn init<B: Backend>(&self) -> TransformerEncoder<B>
Initialize a new transformer encoder module.
sourcepub fn init_with<B: Backend>(
&self,
record: TransformerEncoderRecord<B>
) -> TransformerEncoder<B>
pub fn init_with<B: Backend>( &self, record: TransformerEncoderRecord<B> ) -> TransformerEncoder<B>
Initialize a new transformer encoder module with a record.
Trait Implementations§
source§impl Clone for TransformerEncoderConfig
impl Clone for TransformerEncoderConfig
source§impl Config for TransformerEncoderConfig
impl Config for TransformerEncoderConfig
source§fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
fn save<P: AsRef<Path>>(&self, file: P) -> Result<()>
Saves the configuration to a file. Read more
source§fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
fn load<P: AsRef<Path>>(file: P) -> Result<Self, ConfigError>
Loads the configuration from a file. Read more
source§fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
fn load_binary(data: &[u8]) -> Result<Self, ConfigError>
Loads the configuration from a binary buffer. Read more
source§impl<'de> Deserialize<'de> for TransformerEncoderConfig
impl<'de> Deserialize<'de> for TransformerEncoderConfig
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for TransformerEncoderConfig
impl Display for TransformerEncoderConfig
Auto Trait Implementations§
impl RefUnwindSafe for TransformerEncoderConfig
impl Send for TransformerEncoderConfig
impl Sync for TransformerEncoderConfig
impl Unpin for TransformerEncoderConfig
impl UnwindSafe for TransformerEncoderConfig
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