| 277 | |
| 278 | template <typename Dtype> |
| 279 | void 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 | |
| 304 | template <typename Dtype> |
| 305 | void SGDSolver<Dtype>::RestoreSolverStateFromBinaryProto( |
nothing calls this directly
no test coverage detected