#include <params_model.h>
Definition at line 31 of file params_model.h.
◆ PassEnum
Enumerator |
---|
PTRAIN_PASS1 | |
PTRAIN_PASS2 | |
PTRAIN_NUM_PASSES | |
Definition at line 34 of file params_model.h.
◆ ParamsModel() [1/2]
tesseract::ParamsModel::ParamsModel |
( |
| ) |
|
|
inline |
◆ ParamsModel() [2/2]
tesseract::ParamsModel::ParamsModel |
( |
const char * |
lang, |
|
|
const GenericVector< float > & |
weights |
|
) |
| |
|
inline |
◆ Clear()
void tesseract::ParamsModel::Clear |
( |
| ) |
|
|
inline |
Definition at line 50 of file params_model.h.
51 for (
auto & p : weights_vec_) p.clear();
◆ ComputeCost()
float tesseract::ParamsModel::ComputeCost |
( |
const float |
features[] | ) |
const |
Definition at line 80 of file params_model.cpp.
81 float unnorm_score = 0.0;
83 unnorm_score += weights_vec_[pass_][f] * features[f];
85 return ClipToRange(-unnorm_score / kScoreScaleFactor,
86 kMinFinalCost, kMaxFinalCost);
◆ Copy()
void tesseract::ParamsModel::Copy |
( |
const ParamsModel & |
other_model | ) |
|
Definition at line 47 of file params_model.cpp.
49 weights_vec_[p] = other_model.weights_for_pass(
50 static_cast<PassEnum>(p));
◆ Equivalent()
bool tesseract::ParamsModel::Equivalent |
( |
const ParamsModel & |
that | ) |
const |
Definition at line 89 of file params_model.cpp.
90 float epsilon = 0.0001;
92 if (weights_vec_[p].size() != that.weights_vec_[p].size())
return false;
93 for (
int i = 0; i < weights_vec_[p].
size(); i++) {
94 if (weights_vec_[p][i] != that.weights_vec_[p][i] &&
95 fabs(weights_vec_[p][i] - that.weights_vec_[p][i]) > epsilon)
◆ Initialized()
bool tesseract::ParamsModel::Initialized |
( |
| ) |
|
|
inline |
◆ LoadFromFp()
bool tesseract::ParamsModel::LoadFromFp |
( |
const char * |
lang, |
|
|
TFile * |
fp |
|
) |
| |
Definition at line 102 of file params_model.cpp.
103 const int kMaxLineSize = 100;
104 char line[kMaxLineSize];
112 while (fp->FGets(line, kMaxLineSize) !=
nullptr) {
115 if (!ParseLine(line, &key, &value))
119 tprintf(
"ParamsModel::Unknown parameter %s\n", key);
123 present.SetValue(idx,
true);
131 tprintf(
"Missing field %s.\n", kParamsTrainingFeatureTypeName[i]);
◆ Print()
void tesseract::ParamsModel::Print |
( |
| ) |
|
Definition at line 37 of file params_model.cpp.
39 tprintf(
"ParamsModel for pass %d lang %s\n", p, lang_.
c_str());
40 for (
int i = 0; i < weights_vec_[p].
size(); ++i) {
41 tprintf(
"%s = %g\n", kParamsTrainingFeatureTypeName[i],
◆ SaveToFile()
bool tesseract::ParamsModel::SaveToFile |
( |
const char * |
full_path | ) |
const |
Definition at line 140 of file params_model.cpp.
143 tprintf(
"Refusing to save ParamsModel that has not been initialized.\n");
146 FILE *fp = fopen(full_path,
"wb");
148 tprintf(
"Could not open %s for writing.\n", full_path);
151 bool all_good =
true;
153 if (fprintf(fp,
"%s %f\n", kParamsTrainingFeatureTypeName[i],
weights[i])
◆ SetPass()
void tesseract::ParamsModel::SetPass |
( |
PassEnum |
pass | ) |
|
|
inline |
◆ weights()
const GenericVector<float>& tesseract::ParamsModel::weights |
( |
| ) |
const |
|
inline |
◆ weights_for_pass()
The documentation for this class was generated from the following files: