#include <params_model.h>
Definition at line 30 of file params_model.h.
◆ PassEnum
Enumerator |
---|
PTRAIN_PASS1 | |
PTRAIN_PASS2 | |
PTRAIN_NUM_PASSES | |
Definition at line 33 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 41 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 78 of file params_model.cpp.
79 float unnorm_score = 0.0;
81 unnorm_score += weights_vec_[pass_][f] * features[f];
83 return ClipToRange(-unnorm_score / kScoreScaleFactor,
84 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 87 of file params_model.cpp.
88 float epsilon = 0.0001;
90 if (weights_vec_[p].size() != that.weights_vec_[p].size())
return false;
91 for (
int i = 0; i < weights_vec_[p].
size(); i++) {
92 if (weights_vec_[p][i] != that.weights_vec_[p][i] &&
93 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 100 of file params_model.cpp.
103 FILE *fp = fopen(full_path,
"rb");
105 tprintf(
"Error opening file %s\n", full_path);
bool LoadFromFp(const char *lang, FILE *fp, inT64 end_offset)
◆ LoadFromFp()
bool tesseract::ParamsModel::LoadFromFp |
( |
const char * |
lang, |
|
|
FILE * |
fp, |
|
|
inT64 |
end_offset |
|
) |
| |
Definition at line 113 of file params_model.cpp.
114 const int kMaxLineSize = 100;
115 char line[kMaxLineSize];
123 while ((end_offset < 0 || ftell(fp) < end_offset) &&
124 fgets(line, kMaxLineSize, fp)) {
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]);
const GenericVector< float > & weights() const
int ParamsTrainingFeatureByName(const char *name)
void init_to_size(int size, T t)
◆ 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
◆ 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])
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: