1 /* ****************************************************** */
2 /* file ibp.h: contains definitions for programs that use */
3 /* 16-bit integer weights */
5 /* Copyright (c) 1993 by Donald R. Tveter */
7 /* ****************************************************** */
31 #define MAXINT 2147483647
47 #define MAXINT 2147483647
48 #define CLOCKS_PER_SEC 1000000.0
53 #define RXSTRSIZE 257 /* max length of string to store rx files */
54 #define FILENAMESIZE 15 /* maximum length of a file name */
55 #define MAXFILES 10 /* maximum number of files on file stack */
56 #define MAXFORMAT 21 /* maximum number of format breaks */
57 #define BUFFSIZE 257 /* maximum size of an input line */
58 #define OUTSTRSIZE 400 /* max size of output string */
59 #define WTTYPE short /* a 16-bit integer */
60 #define WTSIZE 2 /* shorts are two bytes */
61 #define MAXSHORT 32767 /* largest short */
62 #define MINSHORT -32768 /* smallest short */
63 #define HCODE -32768 /* code number for a layer h (2) unit */
64 #define ICODE -32767 /* code number for a layer i (3) unit */
65 #define OCODE -32766 /* code number for a layer j (4) unit */
66 #define CAPHCODE -32764 /* code for a string of h layer units */
67 #define CAPXCODE -32763 /* code for a string of unknown values */
68 #define SKIPCODE -32762 /* temporal difference code to skip pattern */
69 #define DIFFCODE -32761 /* temporal difference code to use diff */
70 #define GT 0 /* a symbol meaning > */
71 #define GE 1 /* a symbol meaning >= */
72 #define TRAIN 0 /* selects training patterns */
73 #define TEST 1 /* selects testing patterns */
74 #define TOL 0 /* selects stats based on tolerance */
75 #define MAX 1 /* selects stats based on max value */
76 #define LOOKUP 1 /* produces lookup table for s function */
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 INT32 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 scale an input by */
114 struct wtnode
*wtlist
; /* the list of weights */
115 struct unit
*next
; /* link to next unit in this layer */
118 typedef struct wtnode
121 WTTYPE
*weight
; /* ptr to weight */
122 WTTYPE
*olddw
; /* ptr to delta wji */
123 WTTYPE
*eta
; /* ptr to eta for the DBD method */
124 INT32
*total
; /* ptr to total of weight changes */
125 WTTYPE
*slope
; /* previous slope */
127 WTTYPE weight
; /* weight from here to backunit */
128 WTTYPE olddw
; /* delta wji from previous iteration */
129 WTTYPE eta
; /* the eta for the DBD method */
130 INT32 total
; /* total weight changes for batch mode */
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 */