Guest User

Untitled

a guest
Jul 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <gflags/gflags.h>
  2. #include <glog/logging.h>
  3.  
  4. #include <cstring>
  5. #include <map>
  6. #include <string>
  7. #include <vector>
  8.  
  9. #include "boost/algorithm/string.hpp"
  10. #include "caffe/caffe.hpp"
  11. #include "caffe/util/signal_handler.h"
  12.  
  13. using caffe::Blob;
  14. using caffe::Caffe;
  15. using caffe::Net;
  16. using caffe::Layer;
  17. using caffe::Solver;
  18. using caffe::shared_ptr;
  19. using caffe::string;
  20. using caffe::Timer;
  21. using caffe::vector;
  22. using std::ostringstream;
  23.  
  24. // Train / Finetune a model.
  25. int main() {
  26.  
  27. caffe::SolverParameter solver_param;
  28. caffe::ReadSolverParamsFromTextFileOrDie("model/lenet_solver.prototxt", &solver_param);
  29.  
  30. solver_param.mutable_train_state()->set_level(0);
  31.  
  32. Caffe::set_mode(Caffe::CPU);
  33.  
  34. caffe::SignalHandler signal_handler(
  35. caffe::SolverAction::STOP,
  36. caffe::SolverAction::SNAPSHOT);
  37.  
  38. shared_ptr<caffe::Solver<float> >
  39. solver(caffe::SolverRegistry<float>::CreateSolver(solver_param));
  40.  
  41. solver->SetActionFunction(signal_handler.GetActionFunction());
  42.  
  43. LOG(INFO) << "Starting Optimization";
  44. solver->Solve();
  45.  
  46. LOG(INFO) << "Optimization Done.";
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment