Several changes:
[jacinto-ai/caffe-jacinto.git] / src / caffe / solver.cpp
index 5c25641ce9caaf19479d8d6e3ab08d98b6dde78d..e02b72f31f657f2bc7bf84c72853d2e64ddb00f7 100644 (file)
@@ -39,6 +39,7 @@ Solver<Dtype>::Solver(const SolverParameter& param)
 
 template <typename Dtype>
 void Solver<Dtype>::Solve(const char* resume_file) {
+  Caffe::set_mode(Caffe::Brew(param_.solver_mode()));
   Caffe::set_phase(Caffe::TRAIN);
   LOG(INFO) << "Solving " << net_->name();
   PreSolve();
@@ -71,6 +72,9 @@ void Solver<Dtype>::Solve(const char* resume_file) {
       Caffe::set_phase(Caffe::TRAIN);
     }
   }
+  // After the optimization is done, always do a snapshot.
+  iter_--;
+  Snapshot();
   LOG(INFO) << "Optimization Done.";
 }