| 25 | namespace fs = boost::filesystem; |
| 26 | |
| 27 | fs::path GetCheckpointPath(const fs::path &train_dir) |
| 28 | { |
| 29 | tensorflow::CheckpointState checkpoint_state; |
| 30 | fs::path ckpt_state_path = train_dir / "checkpoint"; |
| 31 | std::ostringstream ckpt_ss; |
| 32 | if (!(ckpt_ss << std::ifstream(ckpt_state_path.string()).rdbuf())) { |
| 33 | PLOG(ERROR) << "Error reading " << ckpt_state_path; |
| 34 | return ""; |
| 35 | } |
| 36 | if (!google::protobuf::TextFormat::ParseFromString(ckpt_ss.str(), &checkpoint_state)) { |
| 37 | LOG(ERROR) << "Error parsing " << ckpt_state_path << ", buf=" << ckpt_ss.str(); |
| 38 | return ""; |
| 39 | } |
| 40 | fs::path checkpoint_path = checkpoint_state.model_checkpoint_path(); |
| 41 | if (checkpoint_path.is_relative()) { |
| 42 | checkpoint_path = train_dir / checkpoint_path; |
| 43 | } |
| 44 | return checkpoint_path; |
| 45 | } |
| 46 | |
| 47 | bool CopyCheckpoint(const fs::path &from, const fs::path &to) |
| 48 | { |
no outgoing calls
no test coverage detected