#include <params_model.h>
Definition at line 32 of file params_model.h.
◆ PassEnum
Enumerator |
---|
PTRAIN_PASS1 | |
PTRAIN_PASS2 | |
PTRAIN_NUM_PASSES | |
Definition at line 35 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 |
Definition at line 43 of file params_model.h.
const GenericVector< float > & weights() const
◆ Clear()
void tesseract::ParamsModel::Clear |
( |
| ) |
|
|
inline |
◆ ComputeCost()
float tesseract::ParamsModel::ComputeCost |
( |
const float |
features[] | ) |
const |
Definition at line 81 of file params_model.cpp.
82 float unnorm_score = 0.0;
84 unnorm_score += weights_vec_[pass_][f] * features[f];
86 return ClipToRange(-unnorm_score / kScoreScaleFactor,
87 kMinFinalCost, kMaxFinalCost);
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
◆ Copy()
void tesseract::ParamsModel::Copy |
( |
const ParamsModel & |
other_model | ) |
|
Definition at line 48 of file params_model.cpp.
50 weights_vec_[p] = other_model.weights_for_pass(
51 static_cast<PassEnum>(p));
◆ Equivalent()
bool tesseract::ParamsModel::Equivalent |
( |
const ParamsModel & |
that | ) |
const |
Definition at line 90 of file params_model.cpp.
91 float epsilon = 0.0001;
93 if (weights_vec_[p].size() != that.weights_vec_[p].size())
return false;
94 for (
int i = 0; i < weights_vec_[p].
size(); i++) {
95 if (weights_vec_[p][i] != that.weights_vec_[p][i] &&
96 fabs(weights_vec_[p][i] - that.weights_vec_[p][i]) > epsilon)
◆ Initialized()
bool tesseract::ParamsModel::Initialized |
( |
| ) |
|
|
inline |
◆ LoadFromFile()
bool tesseract::ParamsModel::LoadFromFile |
( |
const char * |
lang, |
|
|
const char * |
full_path |
|
) |
| |
Definition at line 103 of file params_model.cpp.
107 if (!fp.Open(full_path,
nullptr)) {
108 tprintf(
"Error opening file %s\n", full_path);
bool LoadFromFp(const char *lang, TFile *fp)
DLLSYM void tprintf(const char *format,...)
◆ LoadFromFp()
bool tesseract::ParamsModel::LoadFromFp |
( |
const char * |
lang, |
|
|
TFile * |
fp |
|
) |
| |
Definition at line 114 of file params_model.cpp.
115 const int kMaxLineSize = 100;
116 char line[kMaxLineSize];
124 while (fp->FGets(line, kMaxLineSize) !=
nullptr) {
127 if (!ParseLine(line, &key, &value))
131 tprintf(
"ParamsModel::Unknown parameter %s\n", key);
135 present.SetValue(idx,
true);
143 tprintf(
"Missing field %s.\n", kParamsTrainingFeatureTypeName[i]);
int ParamsTrainingFeatureByName(const char *name)
void init_to_size(int size, const T &t)
DLLSYM void tprintf(const char *format,...)
const GenericVector< float > & weights() const
◆ Print()
void tesseract::ParamsModel::Print |
( |
| ) |
|
Definition at line 38 of file params_model.cpp.
40 tprintf(
"ParamsModel for pass %d lang %s\n", p, lang_.
string());
41 for (
int i = 0; i < weights_vec_[p].
size(); ++i) {
42 tprintf(
"%s = %g\n", kParamsTrainingFeatureTypeName[i],
const char * string() const
DLLSYM void tprintf(const char *format,...)
◆ SaveToFile()
bool tesseract::ParamsModel::SaveToFile |
( |
const char * |
full_path | ) |
const |
Definition at line 152 of file params_model.cpp.
155 tprintf(
"Refusing to save ParamsModel that has not been initialized.\n");
158 FILE *fp = fopen(full_path,
"wb");
160 tprintf(
"Could not open %s for writing.\n", full_path);
163 bool all_good =
true;
165 if (fprintf(fp,
"%s %f\n", kParamsTrainingFeatureTypeName[i],
weights[i])
DLLSYM void tprintf(const char *format,...)
const GenericVector< float > & weights() const
◆ 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: