pub struct TrainingCheckpoint {
pub epoch: usize,
pub parameters: HashMap<String, Vec<f64>>,
pub optimizer_state: HashMap<String, Vec<f64>>,
pub scheduler_state: Option<HashMap<String, f64>>,
pub train_loss: f64,
pub val_loss: Option<f64>,
pub train_loss_history: Vec<f64>,
pub val_loss_history: Vec<f64>,
pub metrics_history: HashMap<String, Vec<f64>>,
pub learning_rate: f64,
pub best_val_loss: Option<f64>,
}Expand description
Comprehensive checkpoint data structure.
This structure contains all the information needed to fully restore training state, including model parameters, optimizer state, and training history.
Fields§
§epoch: usizeCurrent epoch number.
parameters: HashMap<String, Vec<f64>>Model parameters as flattened vectors.
optimizer_state: HashMap<String, Vec<f64>>Optimizer state as flattened vectors.
scheduler_state: Option<HashMap<String, f64>>Scheduler state (if present).
train_loss: f64Current training loss.
val_loss: Option<f64>Current validation loss (if available).
train_loss_history: Vec<f64>Training loss history.
val_loss_history: Vec<f64>Validation loss history.
metrics_history: HashMap<String, Vec<f64>>Metrics history.
learning_rate: f64Current learning rate.
best_val_loss: Option<f64>Best validation loss seen so far.
Implementations§
Source§impl TrainingCheckpoint
impl TrainingCheckpoint
Sourcepub fn new(
epoch: usize,
parameters: &HashMap<String, Array<f64, Ix2>>,
optimizer_state: &HashMap<String, Vec<f64>>,
scheduler_state: Option<HashMap<String, f64>>,
state: &TrainingState,
train_loss_history: &[f64],
val_loss_history: &[f64],
metrics_history: &HashMap<String, Vec<f64>>,
best_val_loss: Option<f64>,
) -> Self
pub fn new( epoch: usize, parameters: &HashMap<String, Array<f64, Ix2>>, optimizer_state: &HashMap<String, Vec<f64>>, scheduler_state: Option<HashMap<String, f64>>, state: &TrainingState, train_loss_history: &[f64], val_loss_history: &[f64], metrics_history: &HashMap<String, Vec<f64>>, best_val_loss: Option<f64>, ) -> Self
Create a new checkpoint from current training state.
Sourcepub fn save(&self, path: &PathBuf) -> TrainResult<()>
pub fn save(&self, path: &PathBuf) -> TrainResult<()>
Save checkpoint to a file.
Sourcepub fn save_with_compression(
&self,
path: &PathBuf,
compression: CheckpointCompression,
) -> TrainResult<()>
pub fn save_with_compression( &self, path: &PathBuf, compression: CheckpointCompression, ) -> TrainResult<()>
Save checkpoint to a file with compression.
§Arguments
path- Path to save the checkpointcompression- Compression method to use
§Example
use tensorlogic_train::TrainingCheckpoint;
use tensorlogic_train::CheckpointCompression;
use std::path::PathBuf;
// Assuming you have a checkpoint...
// Save with gzip compression
checkpoint.save_with_compression(
&PathBuf::from("/tmp/checkpoint.json.gz"),
CheckpointCompression::Gzip
).unwrap();Sourcepub fn load(path: &PathBuf) -> TrainResult<Self>
pub fn load(path: &PathBuf) -> TrainResult<Self>
Load checkpoint from a file.
Sourcepub fn load_compressed(path: &PathBuf) -> TrainResult<Self>
pub fn load_compressed(path: &PathBuf) -> TrainResult<Self>
Load compressed checkpoint from a file.
Sourcepub fn estimated_size(&self) -> usize
pub fn estimated_size(&self) -> usize
Get the size of the checkpoint in bytes (estimated).
Trait Implementations§
Source§impl Clone for TrainingCheckpoint
impl Clone for TrainingCheckpoint
Source§fn clone(&self) -> TrainingCheckpoint
fn clone(&self) -> TrainingCheckpoint
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 moreSource§impl Debug for TrainingCheckpoint
impl Debug for TrainingCheckpoint
Source§impl<'de> Deserialize<'de> for TrainingCheckpoint
impl<'de> Deserialize<'de> for TrainingCheckpoint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TrainingCheckpoint
impl RefUnwindSafe for TrainingCheckpoint
impl Send for TrainingCheckpoint
impl Sync for TrainingCheckpoint
impl Unpin for TrainingCheckpoint
impl UnwindSafe for TrainingCheckpoint
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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