| 339 | // ---------------------------------------------------------------------------------------- |
| 340 | |
| 341 | void test_normal_1_sample(double label) |
| 342 | { |
| 343 | typedef matrix<double,10,1> sample_type; |
| 344 | |
| 345 | |
| 346 | typedef linear_kernel<sample_type> kernel_type; |
| 347 | |
| 348 | |
| 349 | |
| 350 | svm_c_linear_dcd_trainer<kernel_type> linear_trainer; |
| 351 | |
| 352 | svm_c_linear_dcd_trainer<kernel_type>::optimizer_state state; |
| 353 | |
| 354 | const double C = 10; |
| 355 | linear_trainer.set_epsilon(1e-10); |
| 356 | linear_trainer.set_c(C); |
| 357 | |
| 358 | |
| 359 | linear_trainer.force_last_weight_to_1(true); |
| 360 | linear_trainer.include_bias(false); |
| 361 | |
| 362 | std::vector<sample_type> samples; |
| 363 | std::vector<double> labels; |
| 364 | |
| 365 | // make an instance of a sample vector so we can use it below |
| 366 | sample_type sample; |
| 367 | |
| 368 | sample = 0; |
| 369 | sample(0) = -1; |
| 370 | sample(1) = -1; |
| 371 | sample(9) = 4; |
| 372 | |
| 373 | samples.push_back(sample); |
| 374 | labels.push_back(label); |
| 375 | |
| 376 | for (int i = 0; i < 4; ++i) |
| 377 | { |
| 378 | decision_function<kernel_type> df; |
| 379 | df = linear_trainer.train(samples, labels); |
| 380 | |
| 381 | if (label > 0) |
| 382 | { |
| 383 | DLIB_TEST(std::abs(df(samples[0])-4) < 1e-8); |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | DLIB_TEST(std::abs(df(samples[0])+1) < 1e-8); |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // ---------------------------------------------------------------------------------------- |
| 393 |
no test coverage detected