garage.experiment.snapshotter
¶
Defines SnapshotConfig and Snapshotter.
- SnapshotConfig¶
- class Snapshotter(snapshot_dir=os.path.join(os.getcwd(), 'data/local/experiment'), snapshot_mode='last', snapshot_gap=1)¶
Snapshotter snapshots training data.
When training, it saves data to binary files. When resuming, it loads from saved data.
- Parameters
snapshot_dir (str) – Path to save the log and iteration snapshot.
snapshot_mode (str) – Mode to save the snapshot. Can be either “all” (all iterations will be saved), “last” (only the last iteration will be saved), “gap” (every snapshot_gap iterations are saved), “gap_and_last” (save the last iteration as ‘params.pkl’ and save every snapshot_gap iteration separately), “gap_overwrite” (same as gap but overwrites the last saved snapshot), or “none” (do not save snapshots).
snapshot_gap (int) – Gap between snapshot iterations. Wait this number of iterations before taking another snapshot.
- property snapshot_dir¶
Return the directory of snapshot.
- Returns
The directory of snapshot
- Return type
- property snapshot_mode¶
Return the type of snapshot.
- Returns
- The type of snapshot. Can be “all”, “last”, “gap”,
”gap_overwrite”, “gap_and_last”, or “none”.
- Return type
- property snapshot_gap¶
Return the gap number of snapshot.
- Returns
The gap number of snapshot.
- Return type
- save_itr_params(itr, params)¶
Save the parameters if at the right iteration.
- Parameters
itr (int) – Number of iterations. Used as the index of snapshot.
params (obj) – Content of snapshot to be saved.
- Raises
ValueError – If snapshot_mode is not one of “all”, “last”, “gap”, “gap_overwrite”, “gap_and_last”, or “none”.
- load(load_dir, itr='last')¶
Load one snapshot of parameters from disk.
- Parameters
- Returns
Loaded snapshot.
- Return type
- Raises
ValueError – If itr is neither an integer nor one of (“last”, “first”).
FileNotFoundError – If the snapshot file is not found in load_dir.
NotAFileError – If the snapshot exists but is not a file.