25 : test_data_(max_memory), total_pages_(0), async_running_(false) {}
33 tprintf(
"Failed to load list of eval filenames from %s\n",
56 if (total_pages_ == 0) {
57 result.
add_str_int(
"No test data at iteration", iteration);
60 if (!LockIfNotRunning()) {
61 result.
add_str_int(
"Previous test incomplete, skipping test at iteration",
66 STRING prev_result = test_result_;
68 if (training_errors !=
nullptr) {
69 test_iteration_ = iteration;
70 test_training_errors_ = training_errors;
71 test_model_mgr_ = model_mgr;
72 test_training_stage_ = training_stage;
84 int training_stage,
int verbosity) {
90 return "Deserialize failed";
92 int eval_iteration = 0;
93 double char_error = 0.0;
94 double word_error = 0.0;
96 while (error_count < total_pages_) {
106 if (verbosity > 1 || (verbosity > 0 && result !=
PERFECT)) {
116 char_error *= 100.0 / total_pages_;
117 word_error *= 100.0 / total_pages_;
133 void* LSTMTester::ThreadFunc(
void* lstmtester_void) {
135 lstmtester->test_result_ = lstmtester->
RunEvalSync(
136 lstmtester->test_iteration_, lstmtester->test_training_errors_,
137 lstmtester->test_model_mgr_, lstmtester->test_training_stage_,
139 lstmtester->UnlockRunning();
140 return lstmtester_void;
145 bool LSTMTester::LockIfNotRunning() {
147 if (async_running_)
return false;
148 async_running_ =
true;
153 void LSTMTester::UnlockRunning() {
155 async_running_ =
false;
void InitCharSet(const std::string &traineddata_path)
bool GetComponent(TessdataType type, TFile *fp)
static void StartThread(void *(*func)(void *), void *arg)
Create new thread.
const char * string() const
STRING DecodeLabels(const GenericVector< int > &labels)
void SetIteration(int iteration)
const ImageData * GetPageBySerial(int serial)
bool LoadAllEvalData(const STRING &filenames_file)
Trainability PrepareForBackward(const ImageData *trainingdata, NetworkIO *fwd_outputs, NetworkIO *targets)
LSTMTester(int64_t max_memory)
void add_str_double(const char *str, double number)
const STRING & transcription() const
DLLSYM void tprintf(const char *format,...)
STRING RunEvalSync(int iteration, const double *training_errors, const TessdataManager &model_mgr, int training_stage, int verbosity)
double NewSingleError(ErrorTypes type) const
void add_str_int(const char *str, int number)
STRING RunEvalAsync(int iteration, const double *training_errors, const TessdataManager &model_mgr, int training_stage)
bool LoadFileLinesToStrings(const STRING &filename, GenericVector< STRING > *lines)
bool LoadDocuments(const GenericVector< STRING > &filenames, CachingStrategy cache_strategy, FileReader reader)
bool DeSerialize(const TessdataManager *mgr, TFile *fp)
void LabelsFromOutputs(const NetworkIO &outputs, GenericVector< int > *labels, GenericVector< int > *xcoords)