41 int charsetsize = it->shape_table()->unicharset().size();
42 int shapesize = it->CompactCharsetSize();
43 int fontsize = it->sample_set()->NumFonts();
44 ErrorCounter counter(charsetsize, shapesize, fontsize);
47 clock_t start = clock();
48 int total_samples = 0;
49 double unscaled_error = 0.0;
51 int error_samples = report_level > 3 ? report_level * report_level : 0;
53 for (it->Begin(); !it->AtEnd(); it->Next()) {
54 TrainingSample* mutable_sample = it->MutableSample();
55 int page_index = mutable_sample->page_num();
56 Pix* page_pix = 0 <= page_index && page_index < page_images.
size()
57 ? page_images[page_index] :
NULL;
59 classifier->ClassifySample(*mutable_sample, page_pix, 0, INVALID_UNICHAR_ID,
61 if (mutable_sample->class_id() == 0) {
63 counter.AccumulateJunk(*it->shape_table(), results, mutable_sample);
64 }
else if (counter.AccumulateErrors(report_level > 3, boosting_mode,
65 fontinfo_table, *it->shape_table(),
66 results, mutable_sample) &&
69 tprintf(
"Error on sample %d: Classifier debug output:\n",
70 it->GlobalSampleIndex());
71 int keep_this = it->GetSparseClassID();
72 classifier->ClassifySample(*mutable_sample, page_pix, 1, keep_this,
78 double total_time = 1.0 * (clock() - start) / CLOCKS_PER_SEC;
80 unscaled_error = counter.ReportErrors(report_level, boosting_mode,
82 *it, unichar_error, fonts_report);
83 if (scaled_error !=
NULL) *scaled_error = counter.scaled_error_;
84 if (report_level > 1) {
86 tprintf(
"Errors computed in %.2fs at %.1f μs/char\n",
87 total_time, 1000000.0 * total_time / total_samples);
89 return unscaled_error;
DLLSYM void tprintf(const char *format,...)