| 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 |
nothing calls this directly
no test coverage detected