MCPcopy Create free account
hub / github.com/BVLC/caffe / SnapshotSolverStateToHDF5

Method SnapshotSolverStateToHDF5

src/caffe/solvers/sgd_solver.cpp:279–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

277
278template <typename Dtype>
279void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
280 const string& model_filename) {
281 string snapshot_filename =
282 Solver<Dtype>::SnapshotFilename(".solverstate.h5");
283 LOG(INFO) << "Snapshotting solver state to HDF5 file " << snapshot_filename;
284 hid_t file_hid = H5Fcreate(snapshot_filename.c_str(), H5F_ACC_TRUNC,
285 H5P_DEFAULT, H5P_DEFAULT);
286 CHECK_GE(file_hid, 0)
287 << "Couldn't open " << snapshot_filename << " to save solver state.";
288 hdf5_save_int(file_hid, "iter", this->iter_);
289 hdf5_save_string(file_hid, "learned_net", model_filename);
290 hdf5_save_int(file_hid, "current_step", this->current_step_);
291 hid_t history_hid = H5Gcreate2(file_hid, "history", H5P_DEFAULT, H5P_DEFAULT,
292 H5P_DEFAULT);
293 CHECK_GE(history_hid, 0)
294 << "Error saving solver state to " << snapshot_filename << ".";
295 for (int i = 0; i < history_.size(); ++i) {
296 ostringstream oss;
297 oss << i;
298 hdf5_save_nd_dataset<Dtype>(history_hid, oss.str(), *history_[i]);
299 }
300 H5Gclose(history_hid);
301 H5Fclose(file_hid);
302}
303
304template <typename Dtype>
305void SGDSolver<Dtype>::RestoreSolverStateFromBinaryProto(

Callers

nothing calls this directly

Calls 3

hdf5_save_intFunction · 0.85
hdf5_save_stringFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected