get_mnist.sh: changed the script to generate leveldb as well.
[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   Caffe::SetDevice(0);
23   Caffe::set_mode(Caffe::GPU);
25   SolverParameter solver_param;
26   ReadProtoFromTextFile(argv[1], &solver_param);
28   LOG(INFO) << "Starting Optimization";
29   SGDSolver<float> solver(solver_param);
30   LOG(INFO) << "Loading from " << argv[2];
31   solver.net()->CopyTrainedLayersFrom(string(argv[2]));
32   solver.Solve();
33   LOG(INFO) << "Optimization Done.";
35   return 0;
36 }