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(&self, device: &Device) -> PositionWiseFeedForward
pub fn init(&self, device: &Device) -> PositionWiseFeedForward
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 (const: unstable) · 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 UnsafeUnpin 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<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,
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§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> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§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