Skip to content

Commit

Permalink
Merge pull request #1088 from shelhamer/fix-solverstate-filename
Browse files Browse the repository at this point in the history
Fix snapshot filename for solver states
  • Loading branch information
longjon committed Sep 16, 2014
2 parents 4b1f53c + 4e6d977 commit 0fb2faf
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/caffe/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,20 +308,21 @@ void Solver<Dtype>::Snapshot() {
// For intermediate results, we will also dump the gradient values.
net_->ToProto(&net_param, param_.snapshot_diff());
string filename(param_.snapshot_prefix());
string model_filename, snapshot_filename;
const int kBufferSize = 20;
char iter_str_buffer[kBufferSize];
snprintf(iter_str_buffer, kBufferSize, "_iter_%d", iter_);
filename += iter_str_buffer;
filename += ".caffemodel";
LOG(INFO) << "Snapshotting to " << filename;
WriteProtoToBinaryFile(net_param, filename.c_str());
model_filename = filename + ".caffemodel";
LOG(INFO) << "Snapshotting to " << model_filename;
WriteProtoToBinaryFile(net_param, model_filename.c_str());
SolverState state;
SnapshotSolverState(&state);
state.set_iter(iter_);
state.set_learned_net(filename);
filename += ".solverstate";
LOG(INFO) << "Snapshotting solver state to " << filename;
WriteProtoToBinaryFile(state, filename.c_str());
state.set_learned_net(model_filename);
snapshot_filename = filename + ".solverstate";
LOG(INFO) << "Snapshotting solver state to " << snapshot_filename;
WriteProtoToBinaryFile(state, snapshot_filename.c_str());
}

template <typename Dtype>
Expand Down

0 comments on commit 0fb2faf

Please sign in to comment.