pub struct LSTMBatchTrainer<L: LossFunction, O: Optimizer> {
pub network: LSTMNetwork,
pub loss_function: L,
pub optimizer: O,
pub config: TrainingConfig,
pub metrics_history: Vec<TrainingMetrics>,
}
Expand description
Batch trainer for LSTM networks with configurable loss and optimizer Processes multiple sequences simultaneously for improved performance
Fields§
§network: LSTMNetwork
§loss_function: L
§optimizer: O
§config: TrainingConfig
§metrics_history: Vec<TrainingMetrics>
Implementations§
Source§impl<L: LossFunction, O: Optimizer> LSTMBatchTrainer<L, O>
impl<L: LossFunction, O: Optimizer> LSTMBatchTrainer<L, O>
pub fn new(network: LSTMNetwork, loss_function: L, optimizer: O) -> Self
pub fn with_config(self, config: TrainingConfig) -> Self
Sourcepub fn train_batch(
&mut self,
batch_inputs: &[Vec<Array2<f64>>],
batch_targets: &[Vec<Array2<f64>>],
) -> f64
pub fn train_batch( &mut self, batch_inputs: &[Vec<Array2<f64>>], batch_targets: &[Vec<Array2<f64>>], ) -> f64
Sourcepub fn train(
&mut self,
train_data: &[(Vec<Array2<f64>>, Vec<Array2<f64>>)],
validation_data: Option<&[(Vec<Array2<f64>>, Vec<Array2<f64>>)]>,
batch_size: usize,
)
pub fn train( &mut self, train_data: &[(Vec<Array2<f64>>, Vec<Array2<f64>>)], validation_data: Option<&[(Vec<Array2<f64>>, Vec<Array2<f64>>)]>, batch_size: usize, )
Train for multiple epochs with batch processing
§Arguments
train_data
- Vector of (input_sequences, target_sequences) tuples for trainingvalidation_data
- Optional validation databatch_size
- Number of sequences to process in each batch
Sourcepub fn evaluate_batch(
&mut self,
data: &[(Vec<Array2<f64>>, Vec<Array2<f64>>)],
batch_size: usize,
) -> f64
pub fn evaluate_batch( &mut self, data: &[(Vec<Array2<f64>>, Vec<Array2<f64>>)], batch_size: usize, ) -> f64
Evaluate model performance using batch processing
Sourcepub fn predict_batch(
&mut self,
inputs: &[Vec<Array2<f64>>],
) -> Vec<Vec<Array2<f64>>>
pub fn predict_batch( &mut self, inputs: &[Vec<Array2<f64>>], ) -> Vec<Vec<Array2<f64>>>
Generate predictions using batch processing
pub fn get_latest_metrics(&self) -> Option<&TrainingMetrics>
pub fn get_metrics_history(&self) -> &[TrainingMetrics]
pub fn set_training_mode(&mut self, training: bool)
Auto Trait Implementations§
impl<L, O> Freeze for LSTMBatchTrainer<L, O>
impl<L, O> RefUnwindSafe for LSTMBatchTrainer<L, O>where
L: RefUnwindSafe,
O: RefUnwindSafe,
impl<L, O> Send for LSTMBatchTrainer<L, O>
impl<L, O> Sync for LSTMBatchTrainer<L, O>
impl<L, O> Unpin for LSTMBatchTrainer<L, O>
impl<L, O> UnwindSafe for LSTMBatchTrainer<L, O>where
L: UnwindSafe,
O: UnwindSafe,
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