tesseract
4.00.00dev
|
#include <lstmtrainer.h>
Public Member Functions | |
LSTMTrainer () | |
LSTMTrainer (FileReader file_reader, FileWriter file_writer, CheckPointReader checkpoint_reader, CheckPointWriter checkpoint_writer, const char *model_base, const char *checkpoint_name, int debug_interval, inT64 max_memory) | |
virtual | ~LSTMTrainer () |
bool | TryLoadingCheckpoint (const char *filename) |
void | InitCharSet (const UNICHARSET &unicharset, const STRING &script_dir, int train_flags) |
void | InitCharSet (const UNICHARSET &unicharset, const UnicharCompress &recoder) |
bool | InitNetwork (const STRING &network_spec, int append_index, int net_flags, float weight_range, float learning_rate, float momentum) |
int | InitTensorFlowNetwork (const std::string &tf_proto) |
void | InitIterations () |
double | ActivationError () const |
double | CharError () const |
const double * | error_rates () const |
double | best_error_rate () const |
int | best_iteration () const |
int | learning_iteration () const |
int | improvement_steps () const |
void | set_perfect_delay (int delay) |
const GenericVector< char > & | best_trainer () const |
double | NewSingleError (ErrorTypes type) const |
double | LastSingleError (ErrorTypes type) const |
const DocumentCache & | training_data () const |
DocumentCache * | mutable_training_data () |
Trainability | GridSearchDictParams (const ImageData *trainingdata, int iteration, double min_dict_ratio, double dict_ratio_step, double max_dict_ratio, double min_cert_offset, double cert_offset_step, double max_cert_offset, STRING *results) |
void | SetSerializeMode (SerializeAmount serialize_amount) const |
void | DebugNetwork () |
bool | LoadAllTrainingData (const GenericVector< STRING > &filenames) |
bool | MaintainCheckpoints (TestCallback tester, STRING *log_msg) |
bool | MaintainCheckpointsSpecific (int iteration, const GenericVector< char > *train_model, const GenericVector< char > *rec_model, TestCallback tester, STRING *log_msg) |
void | PrepareLogMsg (STRING *log_msg) const |
void | LogIterations (const char *intro_str, STRING *log_msg) const |
bool | TransitionTrainingStage (float error_threshold) |
int | CurrentTrainingStage () const |
virtual bool | Serialize (TFile *fp) const |
virtual bool | DeSerialize (TFile *fp) |
void | StartSubtrainer (STRING *log_msg) |
SubTrainerResult | UpdateSubtrainer (STRING *log_msg) |
void | ReduceLearningRates (LSTMTrainer *samples_trainer, STRING *log_msg) |
int | ReduceLayerLearningRates (double factor, int num_samples, LSTMTrainer *samples_trainer) |
bool | EncodeString (const STRING &str, GenericVector< int > *labels) const |
void | ConvertToInt () |
const ImageData * | TrainOnLine (LSTMTrainer *samples_trainer, bool batch) |
Trainability | TrainOnLine (const ImageData *trainingdata, bool batch) |
Trainability | PrepareForBackward (const ImageData *trainingdata, NetworkIO *fwd_outputs, NetworkIO *targets) |
bool | SaveTrainingDump (SerializeAmount serialize_amount, const LSTMTrainer *trainer, GenericVector< char > *data) const |
bool | ReadTrainingDump (const GenericVector< char > &data, LSTMTrainer *trainer) |
bool | ReadSizedTrainingDump (const char *data, int size) |
void | SetupCheckpointInfo () |
void | SaveRecognitionDump (GenericVector< char > *data) const |
bool | SaveBestModel (FileWriter writer) const |
STRING | DumpFilename () const |
void | FillErrorBuffer (double new_error, ErrorTypes type) |
![]() | |
LSTMRecognizer () | |
~LSTMRecognizer () | |
int | NumOutputs () const |
int | training_iteration () const |
int | sample_iteration () const |
double | learning_rate () const |
bool | IsHardening () const |
LossType | OutputLossType () const |
bool | SimpleTextOutput () const |
bool | IsIntMode () const |
bool | IsRecoding () const |
CachingStrategy | CacheStrategy () const |
bool | IsTensorFlow () const |
GenericVector< STRING > | EnumerateLayers () const |
Network * | GetLayer (const STRING &id) const |
float | GetLayerLearningRate (const STRING &id) const |
void | ScaleLearningRate (double factor) |
void | ScaleLayerLearningRate (const STRING &id, double factor) |
bool | IsUsingAdaGrad () const |
const UNICHARSET & | GetUnicharset () const |
const Dict * | GetDict () const |
void | SetIteration (int iteration) |
int | NumInputs () const |
int | null_char () const |
bool | Serialize (TFile *fp) const |
bool | DeSerialize (TFile *fp) |
bool | LoadDictionary (const char *lang, TessdataManager *mgr) |
void | RecognizeLine (const ImageData &image_data, bool invert, bool debug, double worst_dict_cert, bool use_alternates, const UNICHARSET *target_unicharset, const TBOX &line_box, float score_ratio, bool one_word, PointerVector< WERD_RES > *words) |
void | WordsFromOutputs (const NetworkIO &outputs, const GenericVector< int > &labels, const GenericVector< int > label_coords, const TBOX &line_box, bool debug, bool use_alternates, bool one_word, float score_ratio, float scale_factor, const UNICHARSET *target_unicharset, PointerVector< WERD_RES > *words) |
void | OutputStats (const NetworkIO &outputs, float *min_output, float *mean_output, float *sd) |
bool | RecognizeLine (const ImageData &image_data, bool invert, bool debug, bool re_invert, float label_threshold, float *scale_factor, NetworkIO *inputs, NetworkIO *outputs) |
WERD_RES * | WordFromOutput (const TBOX &line_box, const NetworkIO &outputs, int word_start, int word_end, float score_ratio, float space_certainty, bool debug, bool use_alternates, const UNICHARSET *target_unicharset, const GenericVector< int > &labels, const GenericVector< int > &label_coords, float scale_factor) |
WERD_RES * | InitializeWord (const TBOX &line_box, int word_start, int word_end, float space_certainty, bool use_alternates, const UNICHARSET *target_unicharset, const GenericVector< int > &labels, const GenericVector< int > &label_coords, float scale_factor) |
STRING | DecodeLabels (const GenericVector< int > &labels) |
void | DisplayForward (const NetworkIO &inputs, const GenericVector< int > &labels, const GenericVector< int > &label_coords, const char *window_name, ScrollView **window) |
Static Public Member Functions | |
static bool | EncodeString (const STRING &str, const UNICHARSET &unicharset, const UnicharCompress *recoder, bool simple_text, int null_char, GenericVector< int > *labels) |
static LSTMRecognizer * | ReadRecognitionDump (const GenericVector< char > &data) |
Protected Member Functions | |
void | EmptyConstructor () |
void | SetUnicharsetProperties (const STRING &script_dir) |
bool | DebugLSTMTraining (const NetworkIO &inputs, const ImageData &trainingdata, const NetworkIO &fwd_outputs, const GenericVector< int > &truth_labels, const NetworkIO &outputs) |
void | DisplayTargets (const NetworkIO &targets, const char *window_name, ScrollView **window) |
bool | ComputeTextTargets (const NetworkIO &outputs, const GenericVector< int > &truth_labels, NetworkIO *targets) |
bool | ComputeCTCTargets (const GenericVector< int > &truth_labels, NetworkIO *outputs, NetworkIO *targets) |
double | ComputeErrorRates (const NetworkIO &deltas, double char_error, double word_error) |
double | ComputeRMSError (const NetworkIO &deltas) |
double | ComputeWinnerError (const NetworkIO &deltas) |
double | ComputeCharError (const GenericVector< int > &truth_str, const GenericVector< int > &ocr_str) |
double | ComputeWordError (STRING *truth_str, STRING *ocr_str) |
void | UpdateErrorBuffer (double new_error, ErrorTypes type) |
void | RollErrorBuffers () |
STRING | UpdateErrorGraph (int iteration, double error_rate, const GenericVector< char > &model_data, TestCallback tester) |
![]() | |
void | SetRandomSeed () |
void | DisplayLSTMOutput (const GenericVector< int > &labels, const GenericVector< int > &xcoords, int height, ScrollView *window) |
void | DebugActivationPath (const NetworkIO &outputs, const GenericVector< int > &labels, const GenericVector< int > &xcoords) |
void | DebugActivationRange (const NetworkIO &outputs, const char *label, int best_choice, int x_start, int x_end) |
void | LabelsFromOutputs (const NetworkIO &outputs, float null_thr, GenericVector< int > *labels, GenericVector< int > *xcoords) |
void | LabelsViaThreshold (const NetworkIO &output, float null_threshold, GenericVector< int > *labels, GenericVector< int > *xcoords) |
void | LabelsViaCTC (const NetworkIO &output, GenericVector< int > *labels, GenericVector< int > *xcoords) |
void | LabelsViaReEncode (const NetworkIO &output, GenericVector< int > *labels, GenericVector< int > *xcoords) |
void | LabelsViaSimpleText (const NetworkIO &output, GenericVector< int > *labels, GenericVector< int > *xcoords) |
BLOB_CHOICE_LIST * | GetBlobChoices (int col, int row, bool debug, const NetworkIO &output, const UNICHARSET *target_unicharset, int x_start, int x_end, float score_ratio) |
bool | AddBlobChoices (int unichar_id, float rating, float certainty, int col, int row, const UNICHARSET *target_unicharset, BLOB_CHOICE_IT *bc_it) |
const char * | DecodeLabel (const GenericVector< int > &labels, int start, int *end, int *decoded) |
const char * | DecodeSingleLabel (int label) |
Static Protected Attributes | |
static const int | kRollingBufferSize_ = 1000 |
Definition at line 89 of file lstmtrainer.h.
tesseract::LSTMTrainer::LSTMTrainer | ( | ) |
Definition at line 73 of file lstmtrainer.cpp.
tesseract::LSTMTrainer::LSTMTrainer | ( | FileReader | file_reader, |
FileWriter | file_writer, | ||
CheckPointReader | checkpoint_reader, | ||
CheckPointWriter | checkpoint_writer, | ||
const char * | model_base, | ||
const char * | checkpoint_name, | ||
int | debug_interval, | ||
inT64 | max_memory | ||
) |
Definition at line 86 of file lstmtrainer.cpp.
|
virtual |
Definition at line 113 of file lstmtrainer.cpp.
|
inline |
Definition at line 136 of file lstmtrainer.h.
|
inline |
Definition at line 143 of file lstmtrainer.h.
|
inline |
Definition at line 146 of file lstmtrainer.h.
|
inline |
Definition at line 152 of file lstmtrainer.h.
|
inline |
Definition at line 139 of file lstmtrainer.h.
|
protected |
Definition at line 1186 of file lstmtrainer.cpp.
|
protected |
Definition at line 1118 of file lstmtrainer.cpp.
|
protected |
Definition at line 1129 of file lstmtrainer.cpp.
|
protected |
Definition at line 1149 of file lstmtrainer.cpp.
|
protected |
Definition at line 1098 of file lstmtrainer.cpp.
|
protected |
Definition at line 1168 of file lstmtrainer.cpp.
Definition at line 1214 of file lstmtrainer.cpp.
|
inline |
Definition at line 257 of file lstmtrainer.h.
|
inline |
Definition at line 213 of file lstmtrainer.h.
|
protected |
Definition at line 1028 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::DebugNetwork | ( | ) |
Definition at line 298 of file lstmtrainer.cpp.
|
virtual |
Definition at line 483 of file lstmtrainer.cpp.
|
protected |
Definition at line 1061 of file lstmtrainer.cpp.
STRING tesseract::LSTMTrainer::DumpFilename | ( | ) | const |
Definition at line 951 of file lstmtrainer.cpp.
|
protected |
Definition at line 967 of file lstmtrainer.cpp.
|
inline |
Definition at line 247 of file lstmtrainer.h.
|
static |
Definition at line 748 of file lstmtrainer.cpp.
|
inline |
Definition at line 140 of file lstmtrainer.h.
void tesseract::LSTMTrainer::FillErrorBuffer | ( | double | new_error, |
ErrorTypes | type | ||
) |
Definition at line 960 of file lstmtrainer.cpp.
Trainability tesseract::LSTMTrainer::GridSearchDictParams | ( | const ImageData * | trainingdata, |
int | iteration, | ||
double | min_dict_ratio, | ||
double | dict_ratio_step, | ||
double | max_dict_ratio, | ||
double | min_cert_offset, | ||
double | cert_offset_step, | ||
double | max_cert_offset, | ||
STRING * | results | ||
) |
Definition at line 248 of file lstmtrainer.cpp.
|
inline |
Definition at line 150 of file lstmtrainer.h.
void tesseract::LSTMTrainer::InitCharSet | ( | const UNICHARSET & | unicharset, |
const STRING & | script_dir, | ||
int | train_flags | ||
) |
Definition at line 138 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::InitCharSet | ( | const UNICHARSET & | unicharset, |
const UnicharCompress & | recoder | ||
) |
Definition at line 152 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::InitIterations | ( | ) |
Definition at line 223 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::InitNetwork | ( | const STRING & | network_spec, |
int | append_index, | ||
int | net_flags, | ||
float | weight_range, | ||
float | learning_rate, | ||
float | momentum | ||
) |
Definition at line 175 of file lstmtrainer.cpp.
int tesseract::LSTMTrainer::InitTensorFlowNetwork | ( | const std::string & | tf_proto | ) |
Definition at line 203 of file lstmtrainer.cpp.
|
inline |
Definition at line 160 of file lstmtrainer.h.
|
inline |
Definition at line 149 of file lstmtrainer.h.
bool tesseract::LSTMTrainer::LoadAllTrainingData | ( | const GenericVector< STRING > & | filenames | ) |
Definition at line 305 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::LogIterations | ( | const char * | intro_str, |
STRING * | log_msg | ||
) | const |
Definition at line 414 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::MaintainCheckpoints | ( | TestCallback | tester, |
STRING * | log_msg | ||
) |
Definition at line 314 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::MaintainCheckpointsSpecific | ( | int | iteration, |
const GenericVector< char > * | train_model, | ||
const GenericVector< char > * | rec_model, | ||
TestCallback | tester, | ||
STRING * | log_msg | ||
) |
|
inline |
Definition at line 168 of file lstmtrainer.h.
|
inline |
Definition at line 154 of file lstmtrainer.h.
Trainability tesseract::LSTMTrainer::PrepareForBackward | ( | const ImageData * | trainingdata, |
NetworkIO * | fwd_outputs, | ||
NetworkIO * | targets | ||
) |
Definition at line 827 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::PrepareLogMsg | ( | STRING * | log_msg | ) | const |
Definition at line 402 of file lstmtrainer.cpp.
|
static |
Definition at line 940 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::ReadSizedTrainingDump | ( | const char * | data, |
int | size | ||
) |
Definition at line 924 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::ReadTrainingDump | ( | const GenericVector< char > & | data, |
LSTMTrainer * | trainer | ||
) |
Definition at line 919 of file lstmtrainer.cpp.
int tesseract::LSTMTrainer::ReduceLayerLearningRates | ( | double | factor, |
int | num_samples, | ||
LSTMTrainer * | samples_trainer | ||
) |
Definition at line 639 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::ReduceLearningRates | ( | LSTMTrainer * | samples_trainer, |
STRING * | log_msg | ||
) |
Definition at line 620 of file lstmtrainer.cpp.
|
protected |
Definition at line 1260 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveBestModel | ( | FileWriter | writer | ) | const |
void tesseract::LSTMTrainer::SaveRecognitionDump | ( | GenericVector< char > * | data | ) | const |
Definition at line 931 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveTrainingDump | ( | SerializeAmount | serialize_amount, |
const LSTMTrainer * | trainer, | ||
GenericVector< char > * | data | ||
) | const |
Definition at line 909 of file lstmtrainer.cpp.
|
virtual |
Definition at line 433 of file lstmtrainer.cpp.
|
inline |
Definition at line 151 of file lstmtrainer.h.
|
inline |
Definition at line 178 of file lstmtrainer.h.
|
protected |
Definition at line 982 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::SetupCheckpointInfo | ( | ) |
void tesseract::LSTMTrainer::StartSubtrainer | ( | STRING * | log_msg | ) |
Definition at line 547 of file lstmtrainer.cpp.
|
inline |
Definition at line 165 of file lstmtrainer.h.
|
inline |
Definition at line 268 of file lstmtrainer.h.
Trainability tesseract::LSTMTrainer::TrainOnLine | ( | const ImageData * | trainingdata, |
bool | batch | ||
) |
Definition at line 794 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::TransitionTrainingStage | ( | float | error_threshold | ) |
Definition at line 423 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::TryLoadingCheckpoint | ( | const char * | filename | ) |
Definition at line 125 of file lstmtrainer.cpp.
|
protected |
Definition at line 1247 of file lstmtrainer.cpp.
|
protected |
Definition at line 1279 of file lstmtrainer.cpp.
SubTrainerResult tesseract::LSTMTrainer::UpdateSubtrainer | ( | STRING * | log_msg | ) |
Definition at line 577 of file lstmtrainer.cpp.
|
protected |
Definition at line 390 of file lstmtrainer.h.
|
protected |
Definition at line 451 of file lstmtrainer.h.
|
protected |
Definition at line 452 of file lstmtrainer.h.
|
protected |
Definition at line 424 of file lstmtrainer.h.
|
protected |
Definition at line 426 of file lstmtrainer.h.
|
protected |
Definition at line 428 of file lstmtrainer.h.
|
protected |
Definition at line 438 of file lstmtrainer.h.
|
protected |
Definition at line 410 of file lstmtrainer.h.
|
protected |
Definition at line 441 of file lstmtrainer.h.
|
protected |
Definition at line 400 of file lstmtrainer.h.
|
protected |
Definition at line 404 of file lstmtrainer.h.
|
protected |
Definition at line 418 of file lstmtrainer.h.
|
protected |
Definition at line 419 of file lstmtrainer.h.
|
protected |
Definition at line 394 of file lstmtrainer.h.
|
protected |
Definition at line 398 of file lstmtrainer.h.
|
protected |
Definition at line 473 of file lstmtrainer.h.
|
protected |
Definition at line 446 of file lstmtrainer.h.
|
protected |
Definition at line 475 of file lstmtrainer.h.
|
protected |
Definition at line 414 of file lstmtrainer.h.
|
protected |
Definition at line 415 of file lstmtrainer.h.
|
protected |
Definition at line 454 of file lstmtrainer.h.
|
staticprotected |
Definition at line 472 of file lstmtrainer.h.
|
protected |
Definition at line 469 of file lstmtrainer.h.
|
protected |
Definition at line 458 of file lstmtrainer.h.
|
protected |
Definition at line 402 of file lstmtrainer.h.
|
protected |
Definition at line 412 of file lstmtrainer.h.
|
protected |
Definition at line 466 of file lstmtrainer.h.
|
protected |
Definition at line 460 of file lstmtrainer.h.
|
protected |
Definition at line 396 of file lstmtrainer.h.
|
mutableprotected |
Definition at line 408 of file lstmtrainer.h.
|
protected |
Definition at line 436 of file lstmtrainer.h.
|
protected |
Definition at line 444 of file lstmtrainer.h.
|
protected |
Definition at line 392 of file lstmtrainer.h.
|
protected |
Definition at line 406 of file lstmtrainer.h.
|
protected |
Definition at line 448 of file lstmtrainer.h.
|
protected |
Definition at line 430 of file lstmtrainer.h.
|
protected |
Definition at line 432 of file lstmtrainer.h.
|
protected |
Definition at line 434 of file lstmtrainer.h.
|
protected |
Definition at line 439 of file lstmtrainer.h.