Do snapshot after computing loss and test accuracy
authorSergio Guadarrama <sguada@gmail.com>
Wed, 22 Jan 2014 23:13:22 +0000 (15:13 -0800)
committerSergio Guadarrama <sguada@gmail.com>
Fri, 24 Jan 2014 01:52:27 +0000 (17:52 -0800)
src/caffe/solver.cpp

index e02b72f..8195840 100644 (file)
@@ -58,10 +58,6 @@ void Solver<Dtype>::Solve(const char* resume_file) {
     ComputeUpdateValue();
     net_->Update();
 
-    // Check if we need to do snapshot
-    if (param_.snapshot() && iter_ % param_.snapshot() == 0) {
-      Snapshot();
-    }
     if (param_.display() && iter_ % param_.display() == 0) {
       LOG(INFO) << "Iteration " << iter_ << ", loss = " << loss;
     }
@@ -71,6 +67,10 @@ void Solver<Dtype>::Solve(const char* resume_file) {
       Test();
       Caffe::set_phase(Caffe::TRAIN);
     }
+    // Check if we need to do snapshot
+    if (param_.snapshot() && iter_ % param_.snapshot() == 0) {
+      Snapshot();
+    }
   }
   // After the optimization is done, always do a snapshot.
   iter_--;