tesseract  3.05.02
tesseract::ConvNetCharClassifier Class Reference

#include <conv_net_classifier.h>

Inheritance diagram for tesseract::ConvNetCharClassifier:
tesseract::CharClassifier

Public Member Functions

 ConvNetCharClassifier (CharSet *char_set, TuningParams *params, FeatureBase *feat_extract)
 
virtual ~ConvNetCharClassifier ()
 
virtual bool Train (CharSamp *char_samp, int ClassID)
 
virtual bool SetLearnParam (char *var_name, float val)
 
void SetNet (tesseract::NeuralNet *net)
 
virtual CharAltListClassify (CharSamp *char_samp)
 
virtual int CharCost (CharSamp *char_samp)
 
- Public Member Functions inherited from tesseract::CharClassifier
 CharClassifier (CharSet *char_set, TuningParams *params, FeatureBase *feat_extract)
 
virtual ~CharClassifier ()
 
FeatureBaseFeatureExtractor ()
 
bool CaseSensitive () const
 
void SetCaseSensitive (bool case_sensitive)
 

Additional Inherited Members

- Protected Attributes inherited from tesseract::CharClassifier
FeatureBasefeat_extract_
 
CharSetchar_set_
 
TuningParamsparams_
 
int ** fold_sets_
 
int * fold_set_len_
 
int fold_set_cnt_
 
bool init_
 
bool case_sensitive_
 

Detailed Description

Definition at line 48 of file conv_net_classifier.h.

Constructor & Destructor Documentation

◆ ConvNetCharClassifier()

tesseract::ConvNetCharClassifier::ConvNetCharClassifier ( CharSet char_set,
TuningParams params,
FeatureBase feat_extract 
)

Definition at line 38 of file conv_net_classifier.cpp.

41  : CharClassifier(char_set, params, feat_extract) {
42  char_net_ = NULL;
43  net_input_ = NULL;
44  net_output_ = NULL;
45 }
CharClassifier(CharSet *char_set, TuningParams *params, FeatureBase *feat_extract)

◆ ~ConvNetCharClassifier()

tesseract::ConvNetCharClassifier::~ConvNetCharClassifier ( )
virtual

Definition at line 47 of file conv_net_classifier.cpp.

47  {
48  if (char_net_ != NULL) {
49  delete char_net_;
50  char_net_ = NULL;
51  }
52 
53  if (net_input_ != NULL) {
54  delete []net_input_;
55  net_input_ = NULL;
56  }
57 
58  if (net_output_ != NULL) {
59  delete []net_output_;
60  net_output_ = NULL;
61  }
62 }

Member Function Documentation

◆ CharCost()

int tesseract::ConvNetCharClassifier::CharCost ( CharSamp char_samp)
virtual

return the cost of being a char

Implements tesseract::CharClassifier.

Definition at line 176 of file conv_net_classifier.cpp.

176  {
177  if (RunNets(char_samp) == false) {
178  return 0;
179  }
180  return CubeUtils::Prob2Cost(1.0f - net_output_[0]);
181 }
static int Prob2Cost(double prob_val)
Definition: cube_utils.cpp:37

◆ Classify()

CharAltList * tesseract::ConvNetCharClassifier::Classify ( CharSamp char_samp)
virtual

classifies a charsamp and returns an alternate list of chars sorted by char costs

Implements tesseract::CharClassifier.

Definition at line 187 of file conv_net_classifier.cpp.

187  {
188  // run the needed nets
189  if (RunNets(char_samp) == false) {
190  return NULL;
191  }
192 
193  int class_cnt = char_set_->ClassCount();
194 
195  // create an altlist
196  CharAltList *alt_list = new CharAltList(char_set_, class_cnt);
197 
198  for (int out = 1; out < class_cnt; out++) {
199  int cost = CubeUtils::Prob2Cost(net_output_[out]);
200  alt_list->Insert(out, cost);
201  }
202 
203  return alt_list;
204 }
static int Prob2Cost(double prob_val)
Definition: cube_utils.cpp:37
int ClassCount() const
Definition: char_set.h:111

◆ SetLearnParam()

bool tesseract::ConvNetCharClassifier::SetLearnParam ( char *  var_name,
float  val 
)
virtual

A secondary function needed for training. Allows the trainer to set the value of any train-time parameter. This function is currently not implemented. TODO(ahmadab): implement end-2-end training

Implements tesseract::CharClassifier.

Definition at line 78 of file conv_net_classifier.cpp.

78  {
79  // TODO(ahmadab): implementation of parameter initializing.
80  return false;
81 }

◆ SetNet()

void tesseract::ConvNetCharClassifier::SetNet ( tesseract::NeuralNet char_net)

Set an external net (for training purposes)

Definition at line 209 of file conv_net_classifier.cpp.

209  {
210  if (char_net_ != NULL) {
211  delete char_net_;
212  char_net_ = NULL;
213  }
214  char_net_ = char_net;
215 }

◆ Train()

bool tesseract::ConvNetCharClassifier::Train ( CharSamp char_samp,
int  ClassID 
)
virtual

The main training function. Given a sample and a class ID the classifier updates its parameters according to its learning algorithm. This function is currently not implemented. TODO(ahmadab): implement end-2-end training

Implements tesseract::CharClassifier.

Definition at line 69 of file conv_net_classifier.cpp.

69  {
70  return false;
71 }

The documentation for this class was generated from the following files: