1 /* ***************************************************** */
2 /* file rbp.h: contains definitions for the rbp program */
3 /* that uses 64-bit floating point weights */
5 /* Copyright (c) 1990-1996 by Donald R. Tveter */
7 /* *******************************************************/
29 #define MAXINT 2147483647
44 #define MAXINT 2147483647
46 #define CLOCKS_PER_SEC 1000000.0
61 #define RXSTRSIZE 257 /* max length of string to store rx files */
62 #define MAXFORMAT 21 /* maximum number of format breaks */
63 #define BUFFSIZE 257 /* maximum input buffer size */
64 #define OUTSTRSIZE 400 /* max length of output string */
65 #define FILENAMESIZE 15 /* maximum length of a file name */
66 #define MAXFILES 10 /* maximum number of files on file stack */
67 #define HCODE -32768 /* code number for a layer h (2) unit */
68 #define ICODE -32767 /* code number for an input layer unit */
69 #define OCODE -32766 /* code number for an output layer unit */
70 #define CAPHCODE -32764 /* code for a string of h layer units */
71 #define CAPXCODE -32763 /* code for a string of unknown values */
72 #define SKIPCODE -32762 /* temporal difference code to skip pattern */
73 #define DIFFCODE -32761 /* temporal difference code to use diff */
74 #define GT 0 /* a symbol meaning > */
75 #define GE 1 /* a symbol meaning >= */
76 #define scale(x) x /* scale not used in real version */
77 #define unscale(x) x /* unscale not used in real version */
78 #define unscaleint(x) x /* unscaleint not used in real version */
79 #define TRAIN 0 /* selects the training patterns */
80 #define TEST 1 /* selects the test patterns */
81 #define TOL 0 /* selects stats based on tolerance */
82 #define MAX 1 /* selects stats based on max value */
84 typedef struct seednode
86 unsigned val
; /* a seed value */
87 struct seednode
*next
; /* pointer to next node */
90 typedef struct patnode
92 WTTYPE
*addr
; /* address to get the value from */
93 WTTYPE val
; /* a normal value */
94 short layer
; /* layer of the net to take value from */
95 short unitno
; /* unit of the layer to take value from */
98 typedef struct patlist
100 PATNODE
*pats
; /* the list of patterns */
101 struct patlist
*next
; /* pointer to the next pattern */
106 int inuse
; /* flags unit in use */
107 short layernumber
; /* layer number of the unit */
108 short unitnumber
; /* position within layer */
109 REAL error
; /* to sum error factors */
110 WTTYPE oj
; /* state of activation of node */
111 WTTYPE tj
; /* a temporary variable */
112 WTTYPE translate
; /* the amount to translate an input by */
113 WTTYPE userscale
; /* the amount to divide an input by */
114 struct wtnode
*wtlist
; /* to list of weights to prev layer */
115 struct unit
*next
; /* link to next unit in this layer */
118 typedef struct wtnode
121 WTTYPE
*weight
; /* weight from here to backunit */
122 WTTYPE
*olddw
; /* delta wji from previous iteration */
123 WTTYPE
*total
; /* total of changes for batch updates */
124 WTTYPE
*eta
; /* the eta of the DBD method */
125 WTTYPE
*slope
; /* previous slope */
127 WTTYPE weight
; /* weight from here to backunit */
128 WTTYPE olddw
; /* delta wji from previous iteration */
129 WTTYPE total
; /* total of changes for batch updates */
130 WTTYPE eta
; /* the eta of the DBD method */
131 WTTYPE slope
; /* previous slope */
133 short inuse
; /* 0 if unused, > 0 otherwise */
134 struct wtnode
*next
; /* link to next node */
135 UNIT
*backunit
; /* ptr to unit the weight comes from */
140 char activation
; /* activation function for this layer */
141 WTTYPE D
; /* gain for this layer */
142 WTTYPE biasact
; /* bias act. value for this layer */
143 int unitcount
; /* number of units in this layer now */
144 int initialcount
; /* number of units to start with */
145 struct layer
*backlayer
; /* pointer to previous layer */
146 struct layer
*next
; /* pointer to next layer */
147 UNIT
*units
; /* start of list of units in this layer */
148 PATLIST
*patstart
[2]; /* to the list of patterns */
149 PATLIST
*currentpat
[2]; /* the current pattern */
154 int uncertain
; /* flags values created by continuous */
155 /* updates in the forward pass */
156 int off
; /* -1 for off by 1, 0 otherwise */
157 int npats
; /* number of patterns */
158 INT32 iterno
; /* iteration number when data was found */
159 int right
; /* number of patterns right */
160 int wrong
; /* number of patterns wrong */
161 float avgerr
; /* average abs error per unit */
162 float pctright
; /* percentage right */