pub struct BiLSTMNetwork {
pub input_size: usize,
pub hidden_size: usize,
pub num_layers: usize,
pub combine_mode: CombineMode,
pub is_training: bool,
/* private fields */
}
Expand description
Bidirectional LSTM network for sequence modeling
Fields§
§input_size: usize
§num_layers: usize
§combine_mode: CombineMode
§is_training: bool
Implementations§
Source§impl BiLSTMNetwork
impl BiLSTMNetwork
Sourcepub fn new(
input_size: usize,
hidden_size: usize,
num_layers: usize,
combine_mode: CombineMode,
) -> Self
pub fn new( input_size: usize, hidden_size: usize, num_layers: usize, combine_mode: CombineMode, ) -> Self
Creates a new bidirectional LSTM network
§Arguments
input_size
- Size of input featureshidden_size
- Size of hidden state for each directionnum_layers
- Number of bidirectional layerscombine_mode
- How to combine forward and backward outputs
Sourcepub fn new_concat(
input_size: usize,
hidden_size: usize,
num_layers: usize,
) -> Self
pub fn new_concat( input_size: usize, hidden_size: usize, num_layers: usize, ) -> Self
Create BiLSTM with concatenated outputs (most common)
Sourcepub fn new_sum(input_size: usize, hidden_size: usize, num_layers: usize) -> Self
pub fn new_sum(input_size: usize, hidden_size: usize, num_layers: usize) -> Self
Create BiLSTM with summed outputs
Sourcepub fn new_average(
input_size: usize,
hidden_size: usize,
num_layers: usize,
) -> Self
pub fn new_average( input_size: usize, hidden_size: usize, num_layers: usize, ) -> Self
Create BiLSTM with averaged outputs
Sourcepub fn output_size(&self) -> usize
pub fn output_size(&self) -> usize
Get the output size based on combine mode
Sourcepub fn with_input_dropout(self, dropout_rate: f64, variational: bool) -> Self
pub fn with_input_dropout(self, dropout_rate: f64, variational: bool) -> Self
Apply dropout configuration to all cells
pub fn with_recurrent_dropout( self, dropout_rate: f64, variational: bool, ) -> Self
pub fn with_output_dropout(self, dropout_rate: f64) -> Self
pub fn with_zoneout( self, cell_zoneout_rate: f64, hidden_zoneout_rate: f64, ) -> Self
pub fn train(&mut self)
pub fn eval(&mut self)
Sourcepub fn forward_sequence(&mut self, sequence: &[Array2<f64>]) -> Vec<Array2<f64>> ⓘ
pub fn forward_sequence(&mut self, sequence: &[Array2<f64>]) -> Vec<Array2<f64>> ⓘ
Forward pass for a complete sequence
This is the main method for BiLSTM processing. It runs the forward direction from start to end, backward direction from end to start, then combines outputs.
Sourcepub fn forward_sequence_with_cache(
&mut self,
sequence: &[Array2<f64>],
) -> (Vec<Array2<f64>>, BiLSTMNetworkCache)
pub fn forward_sequence_with_cache( &mut self, sequence: &[Array2<f64>], ) -> (Vec<Array2<f64>>, BiLSTMNetworkCache)
Forward pass with caching for training
Sourcepub fn get_forward_cells(&self) -> &[LSTMCell]
pub fn get_forward_cells(&self) -> &[LSTMCell]
Get references to forward and backward cells for serialization
pub fn get_backward_cells(&self) -> &[LSTMCell]
Sourcepub fn get_forward_cells_mut(&mut self) -> &mut [LSTMCell]
pub fn get_forward_cells_mut(&mut self) -> &mut [LSTMCell]
Get mutable references for training mode changes
pub fn get_backward_cells_mut(&mut self) -> &mut [LSTMCell]
Sourcepub fn update_parameters<O: Optimizer>(
&mut self,
forward_gradients: &[LSTMCellGradients],
backward_gradients: &[LSTMCellGradients],
optimizer: &mut O,
)
pub fn update_parameters<O: Optimizer>( &mut self, forward_gradients: &[LSTMCellGradients], backward_gradients: &[LSTMCellGradients], optimizer: &mut O, )
Update parameters for both directions
Sourcepub fn zero_gradients(&self) -> (Vec<LSTMCellGradients>, Vec<LSTMCellGradients>)
pub fn zero_gradients(&self) -> (Vec<LSTMCellGradients>, Vec<LSTMCellGradients>)
Zero gradients for all cells
Trait Implementations§
Source§impl Clone for BiLSTMNetwork
impl Clone for BiLSTMNetwork
Source§fn clone(&self) -> BiLSTMNetwork
fn clone(&self) -> BiLSTMNetwork
Returns a duplicate of the value. Read more
1.0.0 · 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 BiLSTMNetwork
impl RefUnwindSafe for BiLSTMNetwork
impl Send for BiLSTMNetwork
impl Sync for BiLSTMNetwork
impl Unpin for BiLSTMNetwork
impl UnwindSafe for BiLSTMNetwork
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