tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
19 #ifndef TESSERACT_LSTM_NETWORKIO_H_
20 #define TESSERACT_LSTM_NETWORKIO_H_
85 void Copy2DImage(
int batch, Pix* pix,
float black,
float contrast,
100 void SetPixel(
int t,
int f,
int pixel,
float black,
float contrast);
104 void Print(
int num)
const;
108 return int_mode_ ? i_.
dim1() : f_.
dim1();
112 return int_mode_ ? i_.
dim2() : f_.
dim2();
119 const float*
f(
int t)
const {
123 const int8_t*
i(
int t)
const {
131 int_mode_ = is_quantized;
146 const NetworkIO& src,
int src_t,
int src_offset);
151 void Randomize(
int t,
int offset,
int num_features,
TRand* randomizer);
155 float* rating,
float* certainty)
const;
158 float* rating,
float* certainty)
const;
167 int BestLabel(
int t,
int not_this,
int not_that,
float* score)
const;
199 void AddTimeStepPart(
int t,
int offset,
int num_features,
float* inout)
const;
205 const double* input);
215 float Max()
const {
return int_mode_ ? i_.
Max() : f_.
Max(); }
258 template <
class Func>
265 const int8_t* u = i_[t];
266 const int8_t* v = v_io.i_[t];
267 for (
int i = 0;
i < dim; ++
i) {
268 product[
i] =
f(u[
i] / static_cast<double>(INT8_MAX)) * v[
i] /
269 static_cast<double>(INT8_MAX);
272 const float* u = f_[t];
273 const float* v = v_io.f_[t];
274 for (
int i = 0;
i < dim; ++
i) {
275 product[
i] =
f(u[
i]) * v[
i];
282 template <
class Func>
284 double* product)
const {
288 const float* u = f_[u_t];
289 const float* v = v_io.f_[v_t];
291 for (
int i = 0;
i < dim; ++
i) {
292 product[
i] =
f(u[
i]) * v[
i] * w[
i];
298 template <
class Func>
300 double* product)
const {
304 const float* u = f_[t];
305 const float* v = v_io.f_[t];
307 for (
int i = 0;
i < dim; ++
i) {
308 product[
i] +=
f(u[
i]) * v[
i] * w[
i];
314 template <
class Func1,
class Func2>
316 double* product)
const {
321 const float* u = f_[t];
322 const float* v = v_io.f_[t];
324 for (
int i = 0;
i < dim; ++
i) {
325 product[
i] =
f(u[
i]) * g(v[
i]) * w[
i];
332 static int GetPadding(
int num_features);
345 #endif // TESSERACT_LSTM_NETWORKIO_H_
const float * f(int t) const
const int8_t * i(int t) const
void Copy1DGreyImage(int batch, Pix *pix, float black, float contrast, TRand *randomizer)
int BestChoiceOverRange(int t_start, int t_end, int not_this, int null_ch, float *rating, float *certainty) const
void Randomize(int t, int offset, int num_features, TRand *randomizer)
void ZeroInvalidElements()
void ResizeScaled(const NetworkIO &src, int x_scale, int y_scale, int num_features)
void CopyWithYReversal(const NetworkIO &src)
void ComputeCombinerDeltas(const NetworkIO &fwd_deltas, const NetworkIO &base_output)
void set_int_mode(bool is_quantized)
void FuncMultiply3(int u_t, const NetworkIO &v_io, int v_t, const double *w, double *product) const
void ScoresOverRange(int t_start, int t_end, int choice, int null_ch, float *rating, float *certainty) const
void ZeroTimeStepGeneral(int t, int offset, int num_features)
void CopyUnpacking(const NetworkIO &src, int feature_offset, int num_features)
void FuncMultiply(const NetworkIO &v_io, int t, double *product)
const StrideMap & stride_map() const
const GENERIC_2D_ARRAY< float > & float_array() const
void FromPixes(const StaticShape &shape, const std::vector< const Pix * > &pixes, TRand *randomizer)
void FuncMultiply3Add(const NetworkIO &v_io, int t, const double *w, double *product) const
void ResizeFloat(const NetworkIO &src, int num_features)
void CopyWithXYTranspose(const NetworkIO &src)
void set_stride_map(const StrideMap &map)
void ResizeXTo1(const NetworkIO &src, int num_features)
void CopyWithXReversal(const NetworkIO &src)
void CopyWithNormalization(const NetworkIO &src, const NetworkIO &scale)
double ScoreOfLabels(const GenericVector< int > &labels, int start) const
void SetActivations(int t, int label, float ok_score)
void Transpose(TransposedArray *dest) const
void Resize2d(bool int_mode, int width, int num_features)
int CopyPacking(const NetworkIO &src, int feature_offset)
void ClipVector(int t, float range)
void AddTimeStep(int t, double *inout) const
void CombineOutputs(const NetworkIO &base_output, const NetworkIO &combiner_output)
void Print(int num) const
void SetPixel(int t, int f, int pixel, float black, float contrast)
void MaxpoolBackward(const NetworkIO &fwd, const GENERIC_2D_ARRAY< int > &maxes)
void CopyTimeStepFrom(int dest_t, const NetworkIO &src, int src_t)
void FromPix(const StaticShape &shape, const Pix *pix, TRand *randomizer)
int BestLabel(int t, float *score) const
void EnsureBestLabel(int t, int label)
void ReadTimeStep(int t, double *output) const
void Copy2DImage(int batch, Pix *pix, float black, float contrast, TRand *randomizer)
GENERIC_2D_ARRAY< float > * mutable_float_array()
void AddTimeStepPart(int t, int offset, int num_features, float *inout) const
void SubtractAllFromFloat(const NetworkIO &src)
void CopyTimeStepGeneral(int dest_t, int dest_offset, int num_features, const NetworkIO &src, int src_t, int src_offset)
int PositionOfBestMatch(const GenericVector< int > &labels, int start, int end) const
void ResizeToMap(bool int_mode, const StrideMap &stride_map, int num_features)
static float ProbToCertainty(float prob)
void WriteTimeStep(int t, const double *input)
void CopyAll(const NetworkIO &src)
void Func2Multiply3(const NetworkIO &v_io, int t, const double *w, double *product) const
void Resize(const NetworkIO &src, int num_features)
bool AnySuspiciousTruth(float confidence_thr) const
void MaxpoolTimeStep(int dest_t, const NetworkIO &src, int src_t, int *max_line)
void ScaleFloatBy(float factor)
void AddAllToFloat(const NetworkIO &src)
void WriteTimeStepPart(int t, int offset, int num_features, const double *input)