Skip to content

Commit

Permalink
Add solver accuracy plotting (fix BVLC#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidangomez committed Aug 31, 2015
1 parent f47cf25 commit 67b7922
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/caffe/solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class Solver {

// True iff a request to stop early was received.
bool requested_early_exit_;
vector<Dtype> accuracies;

DISABLE_COPY_AND_ASSIGN(Solver);
};
Expand Down
17 changes: 17 additions & 0 deletions src/caffe/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "caffe/util/io.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/util/upgrade_proto.hpp"
#include "caffe/util/plot_data.h"

namespace caffe {

Expand Down Expand Up @@ -411,6 +412,9 @@ void Solver<Dtype>::Test(const int test_net_id) {
loss_msg_stream << " (* " << loss_weight
<< " = " << loss_weight * mean_score << " loss)";
}
if (output_name == "accuracy") {
accuracies.push_back(mean_score);
}
LOG(INFO) << " Test net output #" << i << ": " << output_name << " = "
<< mean_score << loss_msg_stream.str();
}
Expand Down Expand Up @@ -440,6 +444,19 @@ string Solver<Dtype>::SnapshotFilename(const string extension) {
const int kBufferSize = 20;
char iter_str_buffer[kBufferSize];
snprintf(iter_str_buffer, kBufferSize, "_iter_%d", iter_);
filename += iter_str_buffer;
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(model_filename);
state.set_current_step(current_step_);
snapshot_filename = filename + ".solverstate";
LOG(INFO) << "Snapshotting solver state to " << snapshot_filename;
WriteProtoToBinaryFile(state, snapshot_filename.c_str());
drawPNG(filename, accuracies);
return filename + iter_str_buffer + extension;
}

Expand Down

0 comments on commit 67b7922

Please sign in to comment.