tesseract
5.0.0-alpha-619-ge9db
|
Go to the documentation of this file.
20 #include "config_auto.h"
29 #include "allheaders.h"
41 #ifdef INCLUDE_TENSORFLOW
59 static char const*
const kTypeNames[
NT_COUNT] = {
61 "Convolve",
"Maxpool",
62 "Parallel",
"Replicated",
63 "ParBidiLSTM",
"DepParUDLSTM",
64 "Par2dLSTM",
"Series",
65 "Reconfig",
"RTLReversed",
66 "TTBReversed",
"XYTranspose",
68 "Logistic",
"LinLogistic",
71 "Softmax",
"SoftmaxNoCTC",
72 "LSTMSoftmax",
"LSTMBinarySoftmax",
79 needs_to_backprop_(true),
84 forward_win_(nullptr),
85 backward_win_(nullptr),
86 randomizer_(nullptr) {}
90 needs_to_backprop_(true),
96 forward_win_(nullptr),
97 backward_win_(nullptr),
98 randomizer_(nullptr) {}
155 if (!type_name.
Serialize(fp))
return false;
174 for (data = 0; data <
NT_COUNT && type_name != kTypeNames[data]; ++data) {
177 tprintf(
"Invalid network layer type:%s\n", type_name.
c_str());
181 return static_cast<NetworkType>(data);
191 int32_t network_flags;
198 type = getNetworkType(fp);
203 if (!fp->
DeSerialize(&network_flags))
return nullptr;
247 #ifdef INCLUDE_TENSORFLOW
248 network =
new TFNetwork(
name);
250 tprintf(
"TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n");
289 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics
290 Pix* image = matrix.
ToPix();
295 #endif // GRAPHICS_DISABLED
300 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics
301 Pix* image = matrix.
ToPix();
307 #endif // GRAPHICS_DISABLED
310 #ifndef GRAPHICS_DISABLED
314 if (*window ==
nullptr) {
315 int min_size = std::min(width, height);
317 if (min_size < 1) min_size = 1;
325 *window =
new ScrollView(window_name, 80, 100, width, height, width, height,
327 tprintf(
"Created window %s of size %d, %d\n", window_name, width, height);
336 int height = pixGetHeight(pix);
337 window->
Image(pix, 0, 0);
341 #endif // GRAPHICS_DISABLED
virtual void SetRandomizer(TRand *randomizer)
void DisplayForward(const NetworkIO &matrix)
virtual void SetEnableTraining(TrainingState state)
bool needs_to_backprop() const
virtual int InitWeights(float range, TRand *randomizer)
ScrollView * backward_win_
virtual bool SetupNeedsBackprop(bool needs_backprop)
void Image(struct Pix *image, int x_pos, int y_pos)
bool DeSerialize(bool swap, FILE *fp)
bool Serialize(FILE *fp) const
static Network * CreateFromFile(TFile *fp)
const char * c_str() const
bool DeSerialize(char *data, size_t count=1)
bool Serialize(const char *data, size_t count=1)
ScrollView * forward_win_
virtual void SetNetworkFlags(uint32_t flags)
double SignedRand(double range)
const STRING & name() const
static void ClearWindow(bool tess_coords, const char *window_name, int width, int height, ScrollView **window)
static int DisplayImage(Pix *pix, ScrollView *window)
DLLSYM void tprintf(const char *format,...)
double Random(double range)
virtual bool Serialize(TFile *fp) const
void DisplayBackward(const NetworkIO &matrix)
virtual bool DeSerialize(TFile *fp)=0