Struct LstmConfig
pub struct LstmConfig {
pub d_input: usize,
pub d_hidden: usize,
pub bias: bool,
pub initializer: Initializer,
pub batch_first: bool,
pub reverse: bool,
pub clip: Option<f64>,
pub input_forget: bool,
pub gate_activation: ActivationConfig,
pub cell_activation: ActivationConfig,
pub hidden_activation: ActivationConfig,
}Expand description
Configuration to create a Lstm module using the init function.
Fields§
§d_input: usizeThe size of the input features.
The size of the hidden state.
bias: boolIf a bias should be applied during the Lstm transformation.
initializer: InitializerLstm initializer
batch_first: boolIf true, the input tensor is expected to be [batch_size, seq_length, input_size].
If false, the input tensor is expected to be [seq_length, batch_size, input_size].
reverse: boolIf true, process the sequence in reverse order. This is useful for implementing reverse-direction LSTMs (e.g., ONNX reverse direction).
clip: Option<f64>Optional cell state clip threshold. If provided, cell state values are clipped
to the range [-clip, +clip] after each timestep. This can help prevent
exploding values during inference.
input_forget: boolIf true, couples the input and forget gates: f_t = 1 - i_t.
This reduces the number of parameters and is based on GRU-style simplification.
gate_activation: ActivationConfigActivation function for the input, forget, and output gates. Default is Sigmoid, which is standard for LSTM gates.
cell_activation: ActivationConfigActivation function for the cell gate (candidate cell state). Default is Tanh, which is standard for LSTM.
Activation function applied to the cell state before computing hidden output. Default is Tanh, which is standard for LSTM.
Implementations§
§impl LstmConfig
impl LstmConfig
pub fn new(d_input: usize, d_hidden: usize, bias: bool) -> LstmConfig
pub fn new(d_input: usize, d_hidden: usize, bias: bool) -> LstmConfig
Create a new instance of the config.
§impl LstmConfig
impl LstmConfig
pub fn with_initializer(self, initializer: Initializer) -> LstmConfig
pub fn with_initializer(self, initializer: Initializer) -> LstmConfig
Lstm initializer
pub fn with_batch_first(self, batch_first: bool) -> LstmConfig
pub fn with_batch_first(self, batch_first: bool) -> LstmConfig
If true, the input tensor is expected to be [batch_size, seq_length, input_size].
pub fn with_reverse(self, reverse: bool) -> LstmConfig
pub fn with_reverse(self, reverse: bool) -> LstmConfig
If true, process the sequence in reverse order.
pub fn with_input_forget(self, input_forget: bool) -> LstmConfig
pub fn with_input_forget(self, input_forget: bool) -> LstmConfig
If true, couples the input and forget gates: f_t = 1 - i_t.
pub fn with_gate_activation(
self,
gate_activation: ActivationConfig,
) -> LstmConfig
pub fn with_gate_activation( self, gate_activation: ActivationConfig, ) -> LstmConfig
Activation function for the input, forget, and output gates.
pub fn with_cell_activation(
self,
cell_activation: ActivationConfig,
) -> LstmConfig
pub fn with_cell_activation( self, cell_activation: ActivationConfig, ) -> LstmConfig
Activation function for the cell gate (candidate cell state).
Activation function applied to the cell state before computing hidden output.
pub fn with_clip(self, clip: Option<f64>) -> LstmConfig
pub fn with_clip(self, clip: Option<f64>) -> LstmConfig
Set the default value for the field.
Trait Implementations§
§impl Clone for LstmConfig
impl Clone for LstmConfig
§fn clone(&self) -> LstmConfig
fn clone(&self) -> LstmConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Config for LstmConfig
impl Config for LstmConfig
§impl Debug for LstmConfig
impl Debug for LstmConfig
§impl<'de> Deserialize<'de> for LstmConfig
impl<'de> Deserialize<'de> for LstmConfig
§fn deserialize<D>(
deserializer: D,
) -> Result<LstmConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<LstmConfig, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Display for LstmConfig
impl Display for LstmConfig
§impl Serialize for LstmConfig
impl Serialize for LstmConfig
§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 LstmConfig
impl RefUnwindSafe for LstmConfig
impl Send for LstmConfig
impl Sync for LstmConfig
impl Unpin for LstmConfig
impl UnwindSafe for LstmConfig
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
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