pub struct CheckpointManager {
pub dir: PathBuf,
pub max_to_keep: usize,
pub format: CheckpointFormat,
/* private fields */
}Expand description
Manages writing and reading checkpoints under a directory.
Keeps a rolling window of the most-recent max_to_keep checkpoints, deleting
older files automatically after each save.
Fields§
§dir: PathBuf§max_to_keep: usize§format: CheckpointFormatImplementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(
dir: impl AsRef<Path>,
max_to_keep: usize,
format: CheckpointFormat,
) -> Result<Self, CheckpointError>
pub fn new( dir: impl AsRef<Path>, max_to_keep: usize, format: CheckpointFormat, ) -> Result<Self, CheckpointError>
Create a new manager, creating dir if it does not already exist.
Sourcepub fn save(
&mut self,
ckpt: &OptimizerCheckpoint,
) -> Result<PathBuf, CheckpointError>
pub fn save( &mut self, ckpt: &OptimizerCheckpoint, ) -> Result<PathBuf, CheckpointError>
Save ckpt to disk and prune old checkpoints. Returns the saved path.
Sourcepub fn load_latest(&self) -> Result<OptimizerCheckpoint, CheckpointError>
pub fn load_latest(&self) -> Result<OptimizerCheckpoint, CheckpointError>
Load the most recently saved checkpoint.
Sourcepub fn load_at_step(
&self,
step: u64,
) -> Result<OptimizerCheckpoint, CheckpointError>
pub fn load_at_step( &self, step: u64, ) -> Result<OptimizerCheckpoint, CheckpointError>
Load the checkpoint saved at a specific training step.
Auto Trait Implementations§
impl Freeze for CheckpointManager
impl RefUnwindSafe for CheckpointManager
impl Send for CheckpointManager
impl Sync for CheckpointManager
impl Unpin for CheckpointManager
impl UnsafeUnpin for CheckpointManager
impl UnwindSafe for CheckpointManager
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> 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