tesseract  4.00.00dev
tesseract::CTC Class Reference

#include <ctc.h>

Static Public Member Functions

static void NormalizeProbs (NetworkIO *probs)
 
static bool ComputeCTCTargets (const GenericVector< int > &truth_labels, int null_char, const GENERIC_2D_ARRAY< float > &outputs, NetworkIO *targets)
 

Detailed Description

Definition at line 30 of file ctc.h.

Member Function Documentation

◆ ComputeCTCTargets()

bool tesseract::CTC::ComputeCTCTargets ( const GenericVector< int > &  truth_labels,
int  null_char,
const GENERIC_2D_ARRAY< float > &  outputs,
NetworkIO targets 
)
static

Definition at line 53 of file ctc.cpp.

55  {
56  std::unique_ptr<CTC> ctc(new CTC(labels, null_char, outputs));
57  if (!ctc->ComputeLabelLimits()) {
58  return false; // Not enough time.
59  }
60  // Generate simple targets purely from the truth labels by spreading them
61  // evenly over time.
62  GENERIC_2D_ARRAY<float> simple_targets;
63  ctc->ComputeSimpleTargets(&simple_targets);
64  // Add the simple targets as a starter bias to the network outputs.
65  float bias_fraction = ctc->CalculateBiasFraction();
66  simple_targets *= bias_fraction;
67  ctc->outputs_ += simple_targets;
68  NormalizeProbs(&ctc->outputs_);
69  // Run regular CTC on the biased outputs.
70  // Run forward and backward
71  GENERIC_2D_ARRAY<double> log_alphas, log_betas;
72  ctc->Forward(&log_alphas);
73  ctc->Backward(&log_betas);
74  // Normalize and come out of log space with a clipped softmax over time.
75  log_alphas += log_betas;
76  ctc->NormalizeSequence(&log_alphas);
77  ctc->LabelsToClasses(log_alphas, targets);
78  NormalizeProbs(targets);
79  return true;
80 }
static void NormalizeProbs(NetworkIO *probs)
Definition: ctc.h:36

◆ NormalizeProbs()

static void tesseract::CTC::NormalizeProbs ( NetworkIO probs)
inlinestatic

Definition at line 36 of file ctc.h.

36  {
37  NormalizeProbs(probs->mutable_float_array());
38  }
static void NormalizeProbs(NetworkIO *probs)
Definition: ctc.h:36

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