21 #include "config_auto.h" 30 #include "allheaders.h" 42 #ifdef INCLUDE_TENSORFLOW 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;
179 tprintf(
"Invalid network layer type:%s\n", type_name.
string());
203 switch (stub.
type_) {
241 #ifdef INCLUDE_TENSORFLOW 242 network =
new TFNetwork(stub.
name_);
244 tprintf(
"TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n");
283 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics 284 Pix* image = matrix.
ToPix();
289 #endif // GRAPHICS_DISABLED 294 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics 295 Pix* image = matrix.
ToPix();
301 #endif // GRAPHICS_DISABLED 304 #ifndef GRAPHICS_DISABLED 308 if (*window ==
nullptr) {
309 int min_size = std::min(width, height);
311 if (min_size < 1) min_size = 1;
319 *window =
new ScrollView(window_name, 80, 100, width, height, width, height,
321 tprintf(
"Created window %s of size %d, %d\n", window_name, width, height);
330 int height = pixGetHeight(pix);
331 window->
Image(pix, 0, 0);
335 #endif // GRAPHICS_DISABLED bool Serialize(FILE *fp) const
double Random(double range)
static Network * CreateFromFile(TFile *fp)
bool DeSerialize(bool swap, FILE *fp)
const char * string() const
ScrollView * forward_win_
bool DeSerialize(char *data, size_t count=1)
void DisplayBackward(const NetworkIO &matrix)
virtual bool DeSerialize(TFile *fp)
virtual void SetRandomizer(TRand *randomizer)
virtual int InitWeights(float range, TRand *randomizer)
virtual void SetEnableTraining(TrainingState state)
virtual bool SetupNeedsBackprop(bool needs_backprop)
virtual bool Serialize(TFile *fp) const
static void ClearWindow(bool tess_coords, const char *window_name, int width, int height, ScrollView **window)
void DisplayForward(const NetworkIO &matrix)
void Image(struct Pix *image, int x_pos, int y_pos)
static char const *const kTypeNames[NT_COUNT]
bool Serialize(const char *data, size_t count=1)
DLLSYM void tprintf(const char *format,...)
static int DisplayImage(Pix *pix, ScrollView *window)
ScrollView * backward_win_
double SignedRand(double range)
virtual void SetNetworkFlags(uint32_t flags)