Several changes:
[jacinto-ai/caffe-jacinto.git] / examples / finetune_net.cpp
1 // Copyright 2013 Yangqing Jia
2 //
3 // This is a simple script that allows one to quickly finetune a network.
4 // Usage:
5 //    finetune_net solver_proto_file pretrained_net
7 #include <cuda_runtime.h>
9 #include <cstring>
11 #include "caffe/caffe.hpp"
13 using namespace caffe;
15 int main(int argc, char** argv) {
16   ::google::InitGoogleLogging(argv[0]);
17   if (argc < 2) {
18     LOG(ERROR) << "Usage: finetune_net solver_proto_file pretrained_net";
19     return 0;
20   }
22   SolverParameter solver_param;
23   ReadProtoFromTextFile(argv[1], &solver_param);
25   LOG(INFO) << "Starting Optimization";
26   SGDSolver<float> solver(solver_param);
27   LOG(INFO) << "Loading from " << argv[2];
28   solver.net()->CopyTrainedLayersFrom(string(argv[2]));
29   solver.Solve();
30   LOG(INFO) << "Optimization Done.";
32   return 0;
33 }