tesseract
4.0.0-1-g2a2b
|
#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_t max_memory) | |
virtual | ~LSTMTrainer () |
bool | TryLoadingCheckpoint (const char *filename, const char *old_traineddata) |
void | InitCharSet (const std::string &traineddata_path) |
void | InitCharSet (const TessdataManager &mgr) |
bool | InitNetwork (const STRING &network_spec, int append_index, int net_flags, float weight_range, float learning_rate, float momentum, float adam_beta) |
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 |
int32_t | 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 | DebugNetwork () |
bool | LoadAllTrainingData (const GenericVector< STRING > &filenames, CachingStrategy cache_strategy, bool randomly_rotate) |
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 |
bool | Serialize (SerializeAmount serialize_amount, const TessdataManager *mgr, TFile *fp) const |
bool | DeSerialize (const TessdataManager *mgr, 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 |
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) const |
bool | ReadSizedTrainingDump (const char *data, int size, LSTMTrainer *trainer) const |
bool | ReadLocalTrainingDump (const TessdataManager *mgr, const char *data, int size) |
void | SetupCheckpointInfo () |
bool | SaveTraineddata (const STRING &filename) |
void | SaveRecognitionDump (GenericVector< char > *data) const |
STRING | DumpFilename () const |
void | FillErrorBuffer (double new_error, ErrorTypes type) |
std::vector< int > | MapRecoder (const UNICHARSET &old_chset, const UnicharCompress &old_recoder) const |
Public Member Functions inherited from tesseract::LSTMRecognizer | |
LSTMRecognizer () | |
~LSTMRecognizer () | |
int | NumOutputs () const |
int | training_iteration () const |
int | sample_iteration () const |
double | learning_rate () const |
LossType | OutputLossType () const |
bool | SimpleTextOutput () const |
bool | IsIntMode () const |
bool | IsRecoding () 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) |
void | ConvertToInt () |
const UNICHARSET & | GetUnicharset () const |
const UnicharCompress & | GetRecoder () const |
const Dict * | GetDict () const |
void | SetIteration (int iteration) |
int | NumInputs () const |
int | null_char () const |
bool | Load (const char *lang, TessdataManager *mgr) |
bool | Serialize (const TessdataManager *mgr, TFile *fp) const |
bool | DeSerialize (const TessdataManager *mgr, TFile *fp) |
bool | LoadCharsets (const TessdataManager *mgr) |
bool | LoadRecoder (TFile *fp) |
bool | LoadDictionary (const char *lang, TessdataManager *mgr) |
void | RecognizeLine (const ImageData &image_data, bool invert, bool debug, double worst_dict_cert, const TBOX &line_box, PointerVector< WERD_RES > *words, int lstm_choice_mode=0) |
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, bool upside_down, float *scale_factor, NetworkIO *inputs, NetworkIO *outputs) |
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) |
void | LabelsFromOutputs (const NetworkIO &outputs, GenericVector< int > *labels, GenericVector< int > *xcoords) |
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) |
Protected Member Functions | |
void | InitCharSet () |
void | SetNullChar () |
void | EmptyConstructor () |
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) |
Protected Member Functions inherited from tesseract::LSTMRecognizer | |
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 | LabelsViaReEncode (const NetworkIO &output, GenericVector< int > *labels, GenericVector< int > *xcoords) |
void | LabelsViaSimpleText (const NetworkIO &output, GenericVector< int > *labels, GenericVector< int > *xcoords) |
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_t | max_memory | ||
) |
Definition at line 87 of file lstmtrainer.cpp.
|
virtual |
Definition at line 116 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 1187 of file lstmtrainer.cpp.
|
protected |
Definition at line 1119 of file lstmtrainer.cpp.
|
protected |
Definition at line 1130 of file lstmtrainer.cpp.
|
protected |
Definition at line 1150 of file lstmtrainer.cpp.
|
protected |
Definition at line 1099 of file lstmtrainer.cpp.
|
protected |
Definition at line 1169 of file lstmtrainer.cpp.
Definition at line 1215 of file lstmtrainer.cpp.
|
inline |
Definition at line 211 of file lstmtrainer.h.
|
protected |
Definition at line 1029 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::DebugNetwork | ( | ) |
Definition at line 293 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::DeSerialize | ( | const TessdataManager * | mgr, |
TFile * | fp | ||
) |
Definition at line 468 of file lstmtrainer.cpp.
|
protected |
Definition at line 1062 of file lstmtrainer.cpp.
STRING tesseract::LSTMTrainer::DumpFilename | ( | ) | const |
Definition at line 940 of file lstmtrainer.cpp.
|
protected |
Definition at line 1014 of file lstmtrainer.cpp.
|
inline |
Definition at line 246 of file lstmtrainer.h.
|
static |
Definition at line 718 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 949 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 243 of file lstmtrainer.cpp.
|
inline |
Definition at line 150 of file lstmtrainer.h.
|
inline |
Definition at line 109 of file lstmtrainer.h.
|
inline |
Definition at line 113 of file lstmtrainer.h.
|
protected |
Definition at line 992 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::InitIterations | ( | ) |
Definition at line 218 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, | ||
float | adam_beta | ||
) |
Definition at line 171 of file lstmtrainer.cpp.
int tesseract::LSTMTrainer::InitTensorFlowNetwork | ( | const std::string & | tf_proto | ) |
Definition at line 198 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, |
CachingStrategy | cache_strategy, | ||
bool | randomly_rotate | ||
) |
Definition at line 300 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::LogIterations | ( | const char * | intro_str, |
STRING * | log_msg | ||
) | const |
Definition at line 412 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::MaintainCheckpoints | ( | TestCallback | tester, |
STRING * | log_msg | ||
) |
Definition at line 312 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 | ||
) |
std::vector< int > tesseract::LSTMTrainer::MapRecoder | ( | const UNICHARSET & | old_chset, |
const UnicharCompress & | old_recoder | ||
) | const |
Definition at line 957 of file lstmtrainer.cpp.
|
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 798 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::PrepareLogMsg | ( | STRING * | log_msg | ) | const |
Definition at line 400 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::ReadLocalTrainingDump | ( | const TessdataManager * | mgr, |
const char * | data, | ||
int | size | ||
) |
Definition at line 909 of file lstmtrainer.cpp.
|
inline |
Definition at line 296 of file lstmtrainer.h.
|
inline |
Definition at line 291 of file lstmtrainer.h.
int tesseract::LSTMTrainer::ReduceLayerLearningRates | ( | double | factor, |
int | num_samples, | ||
LSTMTrainer * | samples_trainer | ||
) |
Definition at line 609 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::ReduceLearningRates | ( | LSTMTrainer * | samples_trainer, |
STRING * | log_msg | ||
) |
Definition at line 590 of file lstmtrainer.cpp.
|
protected |
Definition at line 1261 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::SaveRecognitionDump | ( | GenericVector< char > * | data | ) | const |
Definition at line 930 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveTraineddata | ( | const STRING & | filename | ) |
Definition at line 921 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::SaveTrainingDump | ( | SerializeAmount | serialize_amount, |
const LSTMTrainer * | trainer, | ||
GenericVector< char > * | data | ||
) | const |
Definition at line 900 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::Serialize | ( | SerializeAmount | serialize_amount, |
const TessdataManager * | mgr, | ||
TFile * | fp | ||
) | const |
Definition at line 431 of file lstmtrainer.cpp.
|
inline |
Definition at line 151 of file lstmtrainer.h.
|
protected |
Definition at line 1005 of file lstmtrainer.cpp.
void tesseract::LSTMTrainer::SetupCheckpointInfo | ( | ) |
void tesseract::LSTMTrainer::StartSubtrainer | ( | STRING * | log_msg | ) |
Definition at line 517 of file lstmtrainer.cpp.
|
inline |
Definition at line 165 of file lstmtrainer.h.
|
inline |
Definition at line 259 of file lstmtrainer.h.
Trainability tesseract::LSTMTrainer::TrainOnLine | ( | const ImageData * | trainingdata, |
bool | batch | ||
) |
Definition at line 765 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::TransitionTrainingStage | ( | float | error_threshold | ) |
Definition at line 421 of file lstmtrainer.cpp.
bool tesseract::LSTMTrainer::TryLoadingCheckpoint | ( | const char * | filename, |
const char * | old_traineddata | ||
) |
Definition at line 128 of file lstmtrainer.cpp.
|
protected |
Definition at line 1248 of file lstmtrainer.cpp.
|
protected |
Definition at line 1280 of file lstmtrainer.cpp.
SubTrainerResult tesseract::LSTMTrainer::UpdateSubtrainer | ( | STRING * | log_msg | ) |
Definition at line 547 of file lstmtrainer.cpp.
|
protected |
Definition at line 397 of file lstmtrainer.h.
|
protected |
Definition at line 457 of file lstmtrainer.h.
|
protected |
Definition at line 458 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 444 of file lstmtrainer.h.
|
protected |
Definition at line 416 of file lstmtrainer.h.
|
protected |
Definition at line 447 of file lstmtrainer.h.
|
protected |
Definition at line 407 of file lstmtrainer.h.
|
protected |
Definition at line 411 of file lstmtrainer.h.
|
protected |
Definition at line 424 of file lstmtrainer.h.
|
protected |
Definition at line 425 of file lstmtrainer.h.
|
protected |
Definition at line 401 of file lstmtrainer.h.
|
protected |
Definition at line 405 of file lstmtrainer.h.
|
protected |
Definition at line 479 of file lstmtrainer.h.
|
protected |
Definition at line 452 of file lstmtrainer.h.
|
protected |
Definition at line 481 of file lstmtrainer.h.
|
protected |
Definition at line 420 of file lstmtrainer.h.
|
protected |
Definition at line 421 of file lstmtrainer.h.
|
protected |
Definition at line 460 of file lstmtrainer.h.
|
staticprotected |
Definition at line 478 of file lstmtrainer.h.
|
protected |
Definition at line 475 of file lstmtrainer.h.
|
protected |
Definition at line 464 of file lstmtrainer.h.
|
protected |
Definition at line 483 of file lstmtrainer.h.
|
protected |
Definition at line 409 of file lstmtrainer.h.
|
protected |
Definition at line 418 of file lstmtrainer.h.
|
protected |
Definition at line 472 of file lstmtrainer.h.
|
protected |
Definition at line 466 of file lstmtrainer.h.
|
protected |
Definition at line 413 of file lstmtrainer.h.
|
protected |
Definition at line 403 of file lstmtrainer.h.
|
protected |
Definition at line 442 of file lstmtrainer.h.
|
protected |
Definition at line 450 of file lstmtrainer.h.
|
protected |
Definition at line 399 of file lstmtrainer.h.
|
protected |
Definition at line 414 of file lstmtrainer.h.
|
protected |
Definition at line 454 of file lstmtrainer.h.
|
protected |
Definition at line 436 of file lstmtrainer.h.
|
protected |
Definition at line 438 of file lstmtrainer.h.
|
protected |
Definition at line 440 of file lstmtrainer.h.
|
protected |
Definition at line 445 of file lstmtrainer.h.