| 351 | // ---------------------------------------------------------------------------------------- |
| 352 | |
| 353 | void make_dataset ( |
| 354 | const matrix<double>& transition_probabilities, |
| 355 | const matrix<double>& emission_probabilities, |
| 356 | std::vector<std::vector<unsigned long> >& samples, |
| 357 | std::vector<std::vector<unsigned long> >& labels, |
| 358 | unsigned long dataset_size |
| 359 | ) |
| 360 | { |
| 361 | samples.clear(); |
| 362 | labels.clear(); |
| 363 | |
| 364 | dlib::rand rnd; |
| 365 | |
| 366 | // now randomly sample some labeled sequences from our Hidden Markov Model |
| 367 | for (unsigned long iter = 0; iter < dataset_size; ++iter) |
| 368 | { |
| 369 | const unsigned long sequence_size = rnd.get_random_32bit_number()%20+3; |
| 370 | std::vector<unsigned long> sample(sequence_size); |
| 371 | std::vector<unsigned long> label(sequence_size); |
| 372 | |
| 373 | unsigned long previous_label = rnd.get_random_32bit_number()%num_label_states; |
| 374 | for (unsigned long i = 0; i < sample.size(); ++i) |
| 375 | { |
| 376 | unsigned long next_label = 0, next_sample = 0; |
| 377 | sample_hmm(rnd, transition_probabilities, emission_probabilities, |
| 378 | previous_label, next_label, next_sample); |
| 379 | |
| 380 | label[i] = next_label; |
| 381 | sample[i] = next_sample; |
| 382 | |
| 383 | previous_label = next_label; |
| 384 | } |
| 385 | |
| 386 | samples.push_back(sample); |
| 387 | labels.push_back(label); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | // ---------------------------------------------------------------------------------------- |
| 392 |
no test coverage detected