Struct PositionWiseFeedForwardConfig
pub struct PositionWiseFeedForwardConfig {
pub d_model: usize,
pub d_ff: usize,
pub dropout: f64,
pub initializer: Initializer,
pub activation: ActivationConfig,
}Expand description
Configuration to create a position-wise feed-forward layer using the init function.
Fields§
§d_model: usizeThe size of the input and output features.
d_ff: usizeThe size of the hidden inner features.
dropout: f64The dropout rate. Default: 0.1
initializer: InitializerThe type of function used to initialize neural network parameters
activation: ActivationConfigThe activation function used between the two linear layers. Default: Gelu
Implementations§
§impl PositionWiseFeedForwardConfig
impl PositionWiseFeedForwardConfig
pub fn new(d_model: usize, d_ff: usize) -> PositionWiseFeedForwardConfig
pub fn new(d_model: usize, d_ff: usize) -> PositionWiseFeedForwardConfig
Create a new instance of the config.
§Arguments
§Required Arguments
§d_model
The size of the input and output features.
§d_ff
The size of the hidden inner features.
§Default Arguments
§dropout
The dropout rate. Default: 0.1
- Defaults to
0.1
§initializer
The type of function used to initialize neural network parameters
- Defaults to
"Initializer::KaimingUniform{gain:1.0/num_traits::Float::sqrt(3.0), fan_out_only:false}"
§activation
The activation function used between the two linear layers. Default: Gelu
- Defaults to
"ActivationConfig::Gelu"
§impl PositionWiseFeedForwardConfig
impl PositionWiseFeedForwardConfig
pub fn with_dropout(self, dropout: f64) -> PositionWiseFeedForwardConfig
pub fn with_dropout(self, dropout: f64) -> PositionWiseFeedForwardConfig
pub fn with_initializer(
self,
initializer: Initializer,
) -> PositionWiseFeedForwardConfig
pub fn with_initializer( self, initializer: Initializer, ) -> PositionWiseFeedForwardConfig
Sets the value for the field initializer.
The type of function used to initialize neural network parameters
- Defaults to
"Initializer::KaimingUniform{gain:1.0/num_traits::Float::sqrt(3.0), fan_out_only:false}"
pub fn with_activation(
self,
activation: ActivationConfig,
) -> PositionWiseFeedForwardConfig
pub fn with_activation( self, activation: ActivationConfig, ) -> PositionWiseFeedForwardConfig
Sets the value for the field activation.
The activation function used between the two linear layers. Default: Gelu
- Defaults to
"ActivationConfig::Gelu"
§impl PositionWiseFeedForwardConfig
impl PositionWiseFeedForwardConfig
pub fn init<B>(
&self,
device: &<B as BackendTypes>::Device,
) -> PositionWiseFeedForward<B>where
B: Backend,
pub fn init<B>(
&self,
device: &<B as BackendTypes>::Device,
) -> PositionWiseFeedForward<B>where
B: Backend,
Initialize a new position-wise feed-forward module.
Trait Implementations§
§impl Clone for PositionWiseFeedForwardConfig
impl Clone for PositionWiseFeedForwardConfig
§fn clone(&self) -> PositionWiseFeedForwardConfig
fn clone(&self) -> PositionWiseFeedForwardConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Config for PositionWiseFeedForwardConfig
impl Config for PositionWiseFeedForwardConfig
§impl Debug for PositionWiseFeedForwardConfig
impl Debug for PositionWiseFeedForwardConfig
§impl<'de> Deserialize<'de> for PositionWiseFeedForwardConfig
impl<'de> Deserialize<'de> for PositionWiseFeedForwardConfig
§fn deserialize<D>(
deserializer: D,
) -> Result<PositionWiseFeedForwardConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<PositionWiseFeedForwardConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Display for PositionWiseFeedForwardConfig
impl Display for PositionWiseFeedForwardConfig
§impl Serialize for PositionWiseFeedForwardConfig
impl Serialize for PositionWiseFeedForwardConfig
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Auto Trait Implementations§
impl Freeze for PositionWiseFeedForwardConfig
impl RefUnwindSafe for PositionWiseFeedForwardConfig
impl Send for PositionWiseFeedForwardConfig
impl Sync for PositionWiseFeedForwardConfig
impl Unpin for PositionWiseFeedForwardConfig
impl UnwindSafe for PositionWiseFeedForwardConfig
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
§impl<C> CloneExpand for Cwhere
C: Clone,
impl<C> CloneExpand for Cwhere
C: Clone,
fn __expand_clone_method(&self, _scope: &mut Scope) -> C
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString]. Read more