pulsatrix 1.1.0
Loading...
Searching...
No Matches
checkpoint.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <map>
9#include <string>
10
12#include "pulsatrix/module.hpp"
13
14namespace pulsatrix {
15
21inline constexpr int kCheckpointFormatVersion = 1;
22
27 bool strict = true;
28};
29
34[[nodiscard]] std::string OptimizerStatePath(const std::string& checkpoint_path);
35
43void SaveCheckpoint(const std::string& path, Module& model, const std::map<std::string, std::string>& metadata = {});
44
50void SaveCheckpoint(const std::string& path, Module& model, const AdamOptimizer& optimizer,
51 const std::map<std::string, std::string>& metadata = {});
52
63void LoadCheckpoint(const std::string& path, Module& model, CheckpointLoadOptions options = {});
64
71void LoadCheckpoint(const std::string& path, Module& model, AdamOptimizer& optimizer,
72 CheckpointLoadOptions options = {});
73
74} // namespace pulsatrix
Adam optimizer – operates uniformly across any Module's parameters().
Adam (Kingma & Ba, 2015): per-parameter moving averages of gradient (m) and squared gradient (v),...
Definition adam_optimizer.hpp:22
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:78
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
constexpr int kCheckpointFormatVersion
The checkpoint format this build writes. Files record it as format_version; a file without one (any p...
Definition checkpoint.hpp:21
std::string OptimizerStatePath(const std::string &checkpoint_path)
Where the optimizer state for checkpoint_path is stored: model.safetensors becomes model....
void SaveCheckpoint(const std::string &path, Module &model, const std::map< std::string, std::string > &metadata={})
Writes every parameter and buffer of model, under their hierarchical names, to a safetensors file wit...
void LoadCheckpoint(const std::string &path, Module &model, CheckpointLoadOptions options={})
Loads parameters and buffers saved by SaveCheckpoint() (or any safetensors file whose names match) in...
Options for LoadCheckpoint().
Definition checkpoint.hpp:24
bool strict
Require the file and the model to have exactly the same names. Shapes are always checked.
Definition checkpoint.hpp:27