MCPcopy Create free account
hub / github.com/davisking/dlib / test1

Function test1

dlib/test/graph_labeler.cpp:290–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288 typename graph_type
289 >
290 void test1(
291 const dlib::array<graph_type>& samples,
292 const std::vector<std::vector<bool> >& labels
293 )
294 {
295 dlog << LINFO << "begin test1()";
296
297 structural_graph_labeling_trainer<vector_type> trainer;
298 //trainer.be_verbose();
299 trainer.set_epsilon(1e-12);
300 graph_labeler<vector_type> labeler = trainer.train(samples, labels);
301
302
303 // test serialization code for the labeler.
304 std::ostringstream sout;
305 serialize(labeler, sout);
306 std::istringstream sin(sout.str());
307 labeler = graph_labeler<vector_type>();
308 deserialize(labeler, sin);
309
310 std::vector<bool> temp;
311 for (unsigned long k = 0; k < samples.size(); ++k)
312 {
313 temp = labeler(samples[k]);
314 for (unsigned long i = 0; i < temp.size(); ++i)
315 {
316 const bool true_label = (labels[k][i] != 0);
317 const bool pred_label = (temp[i] != 0);
318 DLIB_TEST(true_label == pred_label);
319 }
320 }
321
322 matrix<double> cv;
323
324 cv = test_graph_labeling_function(labeler, samples, labels);
325 DLIB_TEST(sum(cv) == 2);
326 cv = cross_validate_graph_labeling_trainer(trainer, samples, labels, 4);
327 DLIB_TEST(sum(cv) == 2);
328
329 dlog << LINFO << "edge weights: " << trans(sparse_to_dense(labeler.get_edge_weights()));
330 dlog << LINFO << "node weights: " << trans(sparse_to_dense(labeler.get_node_weights()));
331 }
332
333
334

Callers

nothing calls this directly

Calls 11

sparse_to_denseFunction · 0.85
serializeFunction · 0.70
deserializeFunction · 0.70
sumFunction · 0.50
transFunction · 0.50
set_epsilonMethod · 0.45
trainMethod · 0.45
strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected