MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / InitTestNets

Method InitTestNets

rtpose_wrapper/src/caffe/solver.cpp:112–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110
111template <typename Dtype>
112void Solver<Dtype>::InitTestNets() {
113 CHECK(Caffe::root_solver());
114 const bool has_net_param = param_.has_net_param();
115 const bool has_net_file = param_.has_net();
116 const int num_generic_nets = has_net_param + has_net_file;
117 CHECK_LE(num_generic_nets, 1)
118 << "Both net_param and net_file may not be specified.";
119 const int num_test_net_params = param_.test_net_param_size();
120 const int num_test_net_files = param_.test_net_size();
121 const int num_test_nets = num_test_net_params + num_test_net_files;
122 if (num_generic_nets) {
123 CHECK_GE(param_.test_iter_size(), num_test_nets)
124 << "test_iter must be specified for each test network.";
125 } else {
126 CHECK_EQ(param_.test_iter_size(), num_test_nets)
127 << "test_iter must be specified for each test network.";
128 }
129 // If we have a generic net (specified by net or net_param, rather than
130 // test_net or test_net_param), we may have an unlimited number of actual
131 // test networks -- the actual number is given by the number of remaining
132 // test_iters after any test nets specified by test_net_param and/or test_net
133 // are evaluated.
134 const int num_generic_net_instances = param_.test_iter_size() - num_test_nets;
135 const int num_test_net_instances = num_test_nets + num_generic_net_instances;
136 if (param_.test_state_size()) {
137 CHECK_EQ(param_.test_state_size(), num_test_net_instances)
138 << "test_state must be unspecified or specified once per test net.";
139 }
140 if (num_test_net_instances) {
141 CHECK_GT(param_.test_interval(), 0);
142 }
143 int test_net_id = 0;
144 vector<string> sources(num_test_net_instances);
145 vector<NetParameter> net_params(num_test_net_instances);
146 for (int i = 0; i < num_test_net_params; ++i, ++test_net_id) {
147 sources[test_net_id] = "test_net_param";
148 net_params[test_net_id].CopyFrom(param_.test_net_param(i));
149 }
150 for (int i = 0; i < num_test_net_files; ++i, ++test_net_id) {
151 sources[test_net_id] = "test_net file: " + param_.test_net(i);
152 ReadNetParamsFromTextFileOrDie(param_.test_net(i),
153 &net_params[test_net_id]);
154 }
155 const int remaining_test_nets = param_.test_iter_size() - test_net_id;
156 if (has_net_param) {
157 for (int i = 0; i < remaining_test_nets; ++i, ++test_net_id) {
158 sources[test_net_id] = "net_param";
159 net_params[test_net_id].CopyFrom(param_.net_param());
160 }
161 }
162 if (has_net_file) {
163 for (int i = 0; i < remaining_test_nets; ++i, ++test_net_id) {
164 sources[test_net_id] = "net file: " + param_.net();
165 ReadNetParamsFromTextFileOrDie(param_.net(), &net_params[test_net_id]);
166 }
167 }
168 test_nets_.resize(num_test_net_instances);
169 for (int i = 0; i < num_test_net_instances; ++i) {

Callers

nothing calls this directly

Calls 7

CopyFromMethod · 0.80
netMethod · 0.80
set_debug_infoMethod · 0.80
resizeMethod · 0.45
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected