Apache Singa
A General Distributed Deep Learning Library
|
The snapshot management. More...
#include <snapshot.h>
Public Types | |
enum | Mode { kRead, kWrite } |
Public Member Functions | |
Snapshot (const std::string &prefix, Mode mode, int max_param_size=10) | |
<prefix>.model is the binary file for parameter key-value pair. More... | |
std::vector< std::pair< std::string, Tensor > > | Read () |
Read parameters saved as tensors from checkpoint file. | |
std::vector< std::pair< std::string, Shape > > | ReadShape () |
Read parameter shapes from description file. | |
Tensor | Read (const std::string &Key) |
Read parameter returned as a tensor for a given parameter name. | |
Shape | ReadShape (const std::string &key) |
Read parameter shape for a given parameter name. | |
void | Write (const std::string &key, const Tensor ¶m) |
Serialize and dump out parameter. More... | |
int | version () const |
available for singa > 1.0.1 | |
The snapshot management.
It dumps the model parameter snapshot as checkpoint files, which coud be used for fine-tuning and deployment. The model paramters are separated from model definition, i.e., net construction. Users either randomly initialize the layer parameters or using the parameters from checkpoint files using Snapshot after creating the neural network.
singa::Snapshot::Snapshot | ( | const std::string & | prefix, |
Mode | mode, | ||
int | max_param_size = 10 |
||
) |
<prefix>.model is the binary file for parameter key-value pair.
<prefix>.meta is the text file describing information about paramters, i.e. name and shape, one line per parameter. kRead for reading snapshot, whereas kWrite for dumping out snapshot. max_param_size: in MB
void singa::Snapshot::Write | ( | const std::string & | key, |
const Tensor & | param | ||
) |
Serialize and dump out parameter.
This method will write two files, one binary file is for serialized tensors, the other csv file is for parameter names and shapes.