blob: 15f431517324157a4d1acd81d977f44f0b92f19c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2013 Yangqing Jia
//
// This is a simple script that allows one to quickly train a network whose
// parameters are specified by text format protocol buffers.
// Usage:
// train_net net_proto_file solver_proto_file
#include <cuda_runtime.h>
#include <cstring>
#include "caffe/blob.hpp"
#include "caffe/common.hpp"
#include "caffe/net.hpp"
#include "caffe/filler.hpp"
#include "caffe/proto/caffe.pb.h"
#include "caffe/util/io.hpp"
#include "caffe/optimization/solver.hpp"
using namespace caffe;
int main(int argc, char** argv) {
cudaSetDevice(0);
Caffe::set_mode(Caffe::GPU);
Caffe::set_phase(Caffe::TRAIN);
NetParameter net_param;
ReadProtoFromTextFile(argv[1], &net_param);
vector<Blob<float>*> bottom_vec;
Net<float> caffe_net(net_param, bottom_vec);
SolverParameter solver_param;
ReadProtoFromTextFile(argv[2], &solver_param);
LOG(ERROR) << "Starting Optimization";
SGDSolver<float> solver(solver_param);
solver.Solve(&caffe_net);
LOG(ERROR) << "Optimization Done.";
return 0;
}
|