Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
support first test run with an iteration offset: test_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
jgong5 authored and daisyden committed Nov 6, 2018
1 parent 4998107 commit 27aa7f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/caffe/proto/caffe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ message SolverBatchSizePair {
// NOTE
// Update the next available ID when you add a new SolverParameter field.
//
// SolverParameter next available ID: 52 (last added: local_gw_ratio)
// SolverParameter next available ID: 53 (last added: test_offset)
message SolverParameter {
//////////////////////////////////////////////////////////////////////////////
// Specifying the train and test networks
Expand Down Expand Up @@ -430,6 +430,9 @@ message SolverParameter {

optional bool local_lr_auto = 50 [default = false];
optional float local_gw_ratio = 51 [default = 0.001];

// Number of iterations before starting the first test run
optional int32 test_offset = 52 [default = 0];
}

// A message that stores the solver snapshots
Expand Down
4 changes: 2 additions & 2 deletions src/caffe/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void Solver<Dtype>::Step(int iters) {
smoothed_loss_ = 0;

while (iter_ < stop_iter) {
if (param_.test_interval() && iter_ % param_.test_interval() == 0
if (param_.test_interval() && (iter_ - param_.test_offset()) % param_.test_interval() == 0
&& (iter_ > 0 || param_.test_initialization())
&& Caffe::root_solver()) {
TestAll();
Expand Down Expand Up @@ -437,7 +437,7 @@ void Solver<Dtype>::Solve(const char* resume_file) {
}

// in multinode last test must be done after weights update
if (param_.test_interval() && iter_ % param_.test_interval() == 0)
if (param_.test_interval() && (iter_ - param_.test_offset()) % param_.test_interval() == 0)
TestAll();

LOG(INFO) << "Optimization Done.";
Expand Down

0 comments on commit 27aa7f7

Please sign in to comment.