tesseract
4.1.0
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
functions.cpp
Go to the documentation of this file.
1
// File: functions.cpp
3
// Description: Static initialize-on-first-use non-linearity functions.
4
// Author: Ray Smith
5
//
6
// (C) Copyright 2014, Google Inc.
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
// http://www.apache.org/licenses/LICENSE-2.0
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
17
18
#include <cmath>
// for exp, tanh
19
#include "
functions.h
"
20
21
namespace
tesseract
{
22
23
#if __cplusplus < 201402 || defined(__clang__) // C++11
24
25
double
TanhTable
[
kTableSize
];
26
double
LogisticTable
[
kTableSize
];
27
28
class
TableInit
{
29
TableInit
() {
30
for
(
int
i = 0; i <
kTableSize
; i++) {
31
TanhTable[i] = tanh(i /
kScaleFactor
);
32
LogisticTable[i] = 1 / (1 + exp(-i /
kScaleFactor
));
33
}
34
}
35
static
TableInit
tableInit;
36
};
37
38
TableInit
TableInit::tableInit;
39
40
#else // C++14 or newer
41
42
constexpr LUTTempl<kTableSize, LUTFuncTanh>
TanhTable
;
43
constexpr LUTTempl<kTableSize, LUTFuncLog>
LogisticTable
;
44
45
#endif
46
47
}
// namespace tesseract.
tesseract::LogisticTable
double LogisticTable[kTableSize]
Definition:
functions.cpp:26
tesseract::kTableSize
constexpr int kTableSize
Definition:
functions.h:34
tesseract::kScaleFactor
constexpr double kScaleFactor
Definition:
functions.h:36
tesseract
Definition:
altorenderer.cpp:24
tesseract::TanhTable
double TanhTable[kTableSize]
Definition:
functions.cpp:25
tesseract::TableInit
Definition:
functions.cpp:28
functions.h
src
lstm
functions.cpp
Generated by
1.8.11