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),
155 if (fp->
FWrite(&data,
sizeof(data), 1) != 1)
return false;
157 if (!type_name.
Serialize(fp))
return false;
159 if (fp->
FWrite(&data,
sizeof(data), 1) != 1)
return false;
161 if (fp->
FWrite(&data,
sizeof(data), 1) != 1)
return false;
163 if (fp->
FWrite(&
ni_,
sizeof(
ni_), 1) != 1)
return false;
164 if (fp->
FWrite(&
no_,
sizeof(
no_), 1) != 1)
return false;
174 if (fp->
FRead(&data,
sizeof(data), 1) != 1)
return false;
181 tprintf(
"Invalid network layer type:%s\n", type_name.
string());
186 if (fp->
FRead(&data,
sizeof(data), 1) != 1)
return false;
188 if (fp->
FRead(&data,
sizeof(data), 1) != 1)
return false;
207 switch (stub.
type_) {
245 #ifdef INCLUDE_TENSORFLOW 246 network =
new TFNetwork(stub.
name_);
248 tprintf(
"TensorFlow not compiled in! -DINCLUDE_TENSORFLOW\n");
286 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics 287 Pix* image = matrix.
ToPix();
292 #endif // GRAPHICS_DISABLED 297 #ifndef GRAPHICS_DISABLED // do nothing if there's no graphics 298 Pix* image = matrix.
ToPix();
304 #endif // GRAPHICS_DISABLED 307 #ifndef GRAPHICS_DISABLED 311 if (*window == NULL) {
312 int min_size =
MIN(width, height);
313 if (min_size < kMinWinSize) {
314 if (min_size < 1) min_size = 1;
315 width = width * kMinWinSize / min_size;
316 height = height * kMinWinSize / min_size;
322 *window =
new ScrollView(window_name, 80, 100, width, height, width, height,
324 tprintf(
"Created window %s of size %d, %d\n", window_name, width, height);
333 int height = pixGetHeight(pix);
334 window->
Image(pix, 0, 0);
338 #endif // GRAPHICS_DISABLED virtual int InitWeights(float range, TRand *randomizer)
virtual void SetRandomizer(TRand *randomizer)
void DisplayForward(const NetworkIO &matrix)
bool DeSerialize(bool swap, FILE *fp)
ScrollView * backward_win_
static Network * CreateFromFile(TFile *fp)
const char * string() const
int FReadEndian(void *buffer, int size, int count)
virtual void SetNetworkFlags(uinT32 flags)
virtual bool DeSerialize(TFile *fp)
bool Serialize(FILE *fp) const
static void ClearWindow(bool tess_coords, const char *window_name, int width, int height, ScrollView **window)
double Random(double range)
static char const *const kTypeNames[NT_COUNT]
int FWrite(const void *buffer, int size, int count)
ScrollView * forward_win_
const STRING & name() const
void Image(struct Pix *image, int x_pos, int y_pos)
double SignedRand(double range)
static int DisplayImage(Pix *pix, ScrollView *window)
virtual bool Serialize(TFile *fp) const
void DisplayBackward(const NetworkIO &matrix)
virtual void SetEnableTraining(TrainingState state)
virtual bool SetupNeedsBackprop(bool needs_backprop)
int FRead(void *buffer, int size, int count)