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

Method Test

rtpose_wrapper/src/caffe/solver.cpp:337–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335
336template <typename Dtype>
337void Solver<Dtype>::Test(const int test_net_id) {
338 CHECK(Caffe::root_solver());
339 LOG(INFO) << "Iteration " << iter_
340 << ", Testing net (#" << test_net_id << ")";
341 CHECK_NOTNULL(test_nets_[test_net_id].get())->
342 ShareTrainedLayersWith(net_.get());
343 vector<Dtype> test_score;
344 vector<int> test_score_output_id;
345 const shared_ptr<Net<Dtype> >& test_net = test_nets_[test_net_id];
346 Dtype loss = 0;
347 for (int i = 0; i < param_.test_iter(test_net_id); ++i) {
348 SolverAction::Enum request = GetRequestedAction();
349 // Check to see if stoppage of testing/training has been requested.
350 while (request != SolverAction::NONE) {
351 if (SolverAction::SNAPSHOT == request) {
352 Snapshot();
353 } else if (SolverAction::STOP == request) {
354 requested_early_exit_ = true;
355 }
356 request = GetRequestedAction();
357 }
358 if (requested_early_exit_) {
359 // break out of test loop.
360 break;
361 }
362
363 Dtype iter_loss;
364 const vector<Blob<Dtype>*>& result =
365 test_net->Forward(&iter_loss);
366 if (param_.test_compute_loss()) {
367 loss += iter_loss;
368 }
369 if (i == 0) {
370 for (int j = 0; j < result.size(); ++j) {
371 const Dtype* result_vec = result[j]->cpu_data();
372 for (int k = 0; k < result[j]->count(); ++k) {
373 test_score.push_back(result_vec[k]);
374 test_score_output_id.push_back(j);
375 }
376 }
377 } else {
378 int idx = 0;
379 for (int j = 0; j < result.size(); ++j) {
380 const Dtype* result_vec = result[j]->cpu_data();
381 for (int k = 0; k < result[j]->count(); ++k) {
382 test_score[idx++] += result_vec[k];
383 }
384 }
385 }
386 }
387 if (requested_early_exit_) {
388 LOG(INFO) << "Test interrupted.";
389 return;
390 }
391 if (param_.test_compute_loss()) {
392 loss /= param_.test_iter(test_net_id);
393 LOG(INFO) << "Test loss: " << loss;
394 }

Callers

nothing calls this directly

Calls 7

GetRequestedActionFunction · 0.85
ForwardMethod · 0.80
countMethod · 0.80
getMethod · 0.45
sizeMethod · 0.45
cpu_dataMethod · 0.45

Tested by

no test coverage detected