MCPcopy Create free account
hub / github.com/BVLC/caffe / Solve

Method Solve

src/caffe/solver.cpp:270–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268
269template <typename Dtype>
270void Solver<Dtype>::Solve(const char* resume_file) {
271 CHECK(Caffe::root_solver());
272 LOG(INFO) << "Solving " << net_->name();
273 LOG(INFO) << "Learning Rate Policy: " << param_.lr_policy();
274
275 // Initialize to false every time we start solving.
276 requested_early_exit_ = false;
277
278 if (resume_file) {
279 LOG(INFO) << "Restoring previous solver status from " << resume_file;
280 Restore(resume_file);
281 }
282
283 // For a network that is trained by the solver, no bottom or top vecs
284 // should be given, and we will just provide dummy vecs.
285 int start_iter = iter_;
286 Step(param_.max_iter() - iter_);
287 // If we haven't already, save a snapshot after optimization, unless
288 // overridden by setting snapshot_after_train := false
289 if (param_.snapshot_after_train()
290 && (!param_.snapshot() || iter_ % param_.snapshot() != 0)) {
291 Snapshot();
292 }
293 if (requested_early_exit_) {
294 LOG(INFO) << "Optimization stopped early.";
295 return;
296 }
297 // After the optimization is done, run an additional train and test pass to
298 // display the train and test loss/outputs if appropriate (based on the
299 // display and test_interval settings, respectively). Unlike in the rest of
300 // training, for the train net we only run a forward pass as we've already
301 // updated the parameters "max_iter" times -- this final pass is only done to
302 // display the loss, which is computed in the forward pass.
303 if (param_.display() && iter_ % param_.display() == 0) {
304 int average_loss = this->param_.average_loss();
305 Dtype loss;
306 net_->Forward(&loss);
307
308 UpdateSmoothedLoss(loss, start_iter, average_loss);
309
310 LOG(INFO) << "Iteration " << iter_ << ", loss = " << smoothed_loss_;
311 }
312 if (param_.test_interval() && iter_ % param_.test_interval() == 0) {
313 TestAll();
314 }
315 LOG(INFO) << "Optimization Done.";
316}
317
318template <typename Dtype>
319void Solver<Dtype>::TestAll() {

Callers 4

trainFunction · 0.45
RunMethod · 0.45
RunLeastSquaresSolverMethod · 0.45
solver_solveFunction · 0.45

Calls 1

ForwardMethod · 0.80

Tested by 1

RunLeastSquaresSolverMethod · 0.36