tesseract  4.0.0-1-g2a2b
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 55 of file ctc.cpp.

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