Struct tensorflow::CheckpointMaker
source · pub struct CheckpointMaker { /* private fields */ }
Expand description
This struct supports saving and restoring variables using Tensorflow checkpoints in SaveV2 format.
First, the user creates a CheckpointMaker
attached to an Scope
indicating the list of variables to be saved/restored.
The CheckpointMaker lazily modifies the graph creating the nodes needed for saving/restoring.
When one wants to save/restore from or into a session, one calls the save/restore methods
Example
let mut scope = Scope::new_root_scope();
// add operations to define the graph
// ...
// let w and b the variables that we wish to save
let mut checkpoint_maker = CheckpointMaker::new(scope.new_sub_scope("checkpoint"),
vec![w.clone(), b.clone()].into_boxed_slice(),
);
let session = Session::new(&SessionOptions::new(), &scope.graph())?;
// run some training
// ...
// to save the training
checkpoint_maker.save(&session, "data/checkpoint")?;
// then we restore in a different session to continue there
let new_session = Session::new(&SessionOptions::new(), &scope.graph())?;
checkpoint_maker.restore(&new_session, "data/checkpoint")?;
Implementations§
source§impl CheckpointMaker
impl CheckpointMaker
sourcepub fn new(scope: Scope, variables: Box<[Variable]>) -> CheckpointMaker
pub fn new(scope: Scope, variables: Box<[Variable]>) -> CheckpointMaker
Creates a new CheckpointMaker for a Scope, with a list of variables to save/restore. The scope is used to modify the graph to add the save and restore ops.
In order to provide a scope for the CheckpointMaker one can use scope.new_sub_scope(“checkpoint”) in order to create the nodes with scoped names.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CheckpointMaker
impl !Send for CheckpointMaker
impl !Sync for CheckpointMaker
impl Unpin for CheckpointMaker
impl !UnwindSafe for CheckpointMaker
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