tesseract  3.05.02
tesseract::HybridNeuralNetCharClassifier Class Reference

#include <hybrid_neural_net_classifier.h>

Inheritance diagram for tesseract::HybridNeuralNetCharClassifier:
tesseract::CharClassifier

Public Member Functions

 HybridNeuralNetCharClassifier (CharSet *char_set, TuningParams *params, FeatureBase *feat_extract)
 
virtual ~HybridNeuralNetCharClassifier ()
 
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 41 of file hybrid_neural_net_classifier.h.

Constructor & Destructor Documentation

◆ HybridNeuralNetCharClassifier()

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

Definition at line 39 of file hybrid_neural_net_classifier.cpp.

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

◆ ~HybridNeuralNetCharClassifier()

tesseract::HybridNeuralNetCharClassifier::~HybridNeuralNetCharClassifier ( )
virtual

Definition at line 48 of file hybrid_neural_net_classifier.cpp.

48  {
49  for (int net_idx = 0; net_idx < nets_.size(); net_idx++) {
50  if (nets_[net_idx] != NULL) {
51  delete nets_[net_idx];
52  }
53  }
54  nets_.clear();
55 
56  if (net_input_ != NULL) {
57  delete []net_input_;
58  net_input_ = NULL;
59  }
60 
61  if (net_output_ != NULL) {
62  delete []net_output_;
63  net_output_ = NULL;
64  }
65 }

Member Function Documentation

◆ CharCost()

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

Implements tesseract::CharClassifier.

Definition at line 170 of file hybrid_neural_net_classifier.cpp.

170  {
171  // it is by design that a character cost is equal to zero
172  // when no nets are present. This is the case during training.
173  if (RunNets(char_samp) == false) {
174  return 0;
175  }
176 
177  return CubeUtils::Prob2Cost(1.0f - net_output_[0]);
178 }
static int Prob2Cost(double prob_val)
Definition: cube_utils.cpp:37

◆ Classify()

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

Implements tesseract::CharClassifier.

Definition at line 182 of file hybrid_neural_net_classifier.cpp.

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

◆ SetLearnParam()

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

Implements tesseract::CharClassifier.

Definition at line 77 of file hybrid_neural_net_classifier.cpp.

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

◆ SetNet()

void tesseract::HybridNeuralNetCharClassifier::SetNet ( tesseract::NeuralNet net)

Definition at line 202 of file hybrid_neural_net_classifier.cpp.

202  {
203 }

◆ Train()

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

Implements tesseract::CharClassifier.

Definition at line 70 of file hybrid_neural_net_classifier.cpp.

70  {
71  return false;
72 }

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