tesseract
5.0.0-alpha-619-ge9db
generate_lut.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
# Create C/C++ code for two lookup tables.
4
5
import
math
6
7
# Size of static tables.
8
kTableSize = 4096
9
# Scale factor for float arg to int index.
10
kScaleFactor = 256.0
11
12
print(
"// Generated code with lookup tables"
)
13
print(
'#include "functions.h"'
)
14
print(
"namespace tesseract {"
)
15
16
print(
"const double TanhTable[] = {"
)
17
for
i
in
range(kTableSize):
18
print(
" %a,"
% math.tanh(i / kScaleFactor))
19
print(
"};"
)
20
21
print(
"const double LogisticTable[] = {"
)
22
for
i
in
range(kTableSize):
23
print(
" %a,"
% (1 / (1 + math.exp(-i / kScaleFactor))))
24
print(
"};"
)
25
print(
"} // namespace tesseract."
)
src
lstm
generate_lut.py
Generated on Thu Jan 30 2020 14:22:20 for tesseract by
1.8.16