tesseract  5.0.0-alpha-619-ge9db
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 54 of file ctc.cpp.

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

◆ 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  }

The documentation for this class was generated from the following files:
GENERIC_2D_ARRAY< float >
tesseract::CTC::NormalizeProbs
static void NormalizeProbs(NetworkIO *probs)
Definition: ctc.h:36