tesseract  5.0.0
tesseract::CTC Class Reference

#include <ctc.h>

Static Public Member Functions

static void NormalizeProbs (NetworkIO *probs)
 
static bool ComputeCTCTargets (const std::vector< 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 std::vector< int > &  truth_labels,
int  null_char,
const GENERIC_2D_ARRAY< float > &  outputs,
NetworkIO targets 
)
static

Definition at line 53 of file ctc.cpp.

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

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