KSquare Utilities
UsfCasCor.h
Go to the documentation of this file.
1 #if !defined(__USFCASCOR__H_)
2 #define __USFCASCOR__H_
3 
4 /**
5  *@brief Adapted by Kurt Kramer be a 'class' definition so as to make it more usable in th ePices software world.
6  *@details The original author is _____________.
7  See notes below for original author, etc.
8 
9  Modified by Kurt Kramer 2012-09-10:
10  Originally written by R. Scott Crowder, III Se below for his comments.
11 
12  I ported this implementation as found at USF into a c++ Class and integrated into the Pices
13  application.
14  1) Restructured code as a c++ class.
15  2) A trained classifier is written to disk and can be reread at a later time.
16  3) Integrated into the Pices application.
17  4) Primary use will to be used in a Dual classifier setup along with a Support Vector Machine(SVM)(libSVM)
18  where both classifiers agree on the prediction will the label be returned otherwise the label
19  "UnKnown" will be returned. User will have option to have the common part of the prediction in the
20  class hierarchy returned instead.
21  5) Added predicted confidence values for each class.
22 
23 
24  Changes made by Steven Eschrich <eschrich@csee.usf.edu>
25  Fall, 2001
26 
27  - The code was heavily modified in the I/O portion to follow
28  C4.5 standard data formats (although currently only real-valued
29  attributes are supported). It parses the .names file for classes
30  (1 of N representation) and feature values (ignore or real). The
31  logic simply treats all non-ignore fields as real so integer labels
32  are treated as continuous.
33 
34  - All network parameters can be passed via command line arguments,
35  try cascor -h for details. Briefly,
36  -i # input epochs
37  -o # output epochs
38  -r # number of new units to add
39  -P make predictions. generates a filestem.pred file with class
40  names as predictions (from a .test file).
41  -N normalize features to 0-1
42  -f filestem Filestem for data
43  -R use training set (re-substitution)
44 
45  All other parameters that could be specified in the .net file are
46  specified as
47  -O option=value (e.g. -O UseCache=True)
48 
49  - Defaults are used for parameters, in case someone starts it without
50  any...
51 
52  - Support for index files (-I option). That is, the following files
53  are supposed to exist
54  filestem.data
55  filestem.idata
56  filestem.itest (-P only)
57  filestem.names
58 
59  The .idata and .itest are text files with the index number of the record
60  in .data desired. The .data file **must** be in fixed-width format, each
61  line padded to the same length with spaces.
62 */
63 /****************************************************************************/
64 /* C implementation of the Cascade-Correlation learning algorithm. */
65 /* */
66 /* Written by: R. Scott Crowder, III */
67 /* School of Computer Science */
68 /* Carnegie Mellon University */
69 /* Pittsburgh, PA 15213-3890 */
70 /* */
71 /* Phone: (412) 268-8139 */
72 /* Internet: rsc@cs.cmu.edu */
73 /* */
74 /* */
75 /* This code has been placed in the public domain by the author. As a */
76 /* matter of simple courtesy, anyone using or adapting this code is */
77 /* expected to acknowledge the source. The author would like to hear */
78 /* about any attempts to use this system, successful or not. */
79 /* */
80 /* This code is a port to C from the original Common Lisp implementation */
81 /* written by Scott E. Fahlman. (Version dated June 1 1990.) */
82 /* */
83 /* For an explanation of this algorithm and some results, see "The */
84 /* Cascade-Correlation Learning Architecture" by Scott E. Fahlman and */
85 /* Christian Lebiere in D. S. Touretzky (ed.), "Advances in Neural */
86 /* Information Processing Systems 2", Morgan Kaufmann, 1990. A somewhat */
87 /* longer version is available as CMU Computer Science Tech Report */
88 /* CMU-CS-90-100. Instructions for Ftping this report are given at the */
89 /* end of this file. */
90 /* */
91 /* An example of the network set up file is provided at the bottom of */
92 /* this file. */
93 /* */
94 /* This code has been successfully compiled on the following machines. */
95 /* */
96 /* DEC Station 3100 using the MIPS compiler version 1.31 */
97 /* Sun 4 using the gcc compiler version 1.23 */
98 /* IBM PC-RT using the cc compiler */
99 /* IBM RS6000 (Model 520) using the xlc compiler */
100 /* 386 machine using the Turbo C 2.0 compiler */
101 /* The implementation compiles with the ANSI standard. Some machine */
102 /* specific preprocessor commands are required. It is assumed that your */
103 /* system will provide the required preprocessor arguments. */
104 /* */
105 /****************************************************************************/
106 /* Change Log */
107 /****************************************************************************/
108 /* */
109 /* Changes from Release 1 dated Jun-12-90 to Version 1.14 Jul-18-90 */
110 /* */
111 /* bug fix in TYPE_CONVERT Thanks to Michael Witbrock for the 1st report */
112 /* bug fix in BUILD_NET Thanks to Michael Witbrock for the 1st report */
113 /* bug fix in GET_ARRAY_ELEMENT Thanks to Ken Lang */
114 /* bug fix in COMPUTE_CORRELATIONS Thanks to Eric Melz */
115 /* bug fix in ADJUST_CORRELATIONS Thanks to Chris Lebiere */
116 /* bug fix in COMPUTE_SLOPES Thanks to Chris Lebiere */
117 /* removed 2nd call to INIT_GLOBALS Thanks to Dimitris Michailidis */
118 /* Added UnitType ASYMSIGMOID for users who like sigmoids to go from 0-1 */
119 /* all learning utility functions changed with this addition. */
120 /* Added command line argument option type 'cascor1 help' for usage info. */
121 /* Added .net file and on-the-fly parameter adjustment code. See new */
122 /* samples files at the end of this listing for examples. Functions */
123 /* main and GET_NETWORK_CONFIGURATION have changed completely. */
124 /* GET_USER_INPUT replaced by Y_OR_N_P */
125 //* <signal.h> included to support on-the-fly parameter updating */
126 /****************************************************************************/
127 /* */
128 /* Changes from Version 1.15 Jul-18-90 to 1.16 Oct-24-90 */
129 /* */
130 /* bug fix in BUILD_NETWORK, INSTALL_NEW_UNIT, and TRAIN to allow */
131 /* NTestPatterns > NTrainingPatterns. Thanks to William Stevenson */
132 /****************************************************************************/
133 /* */
134 /* Changes from Version 1.16 Oct-24-90 to 1.17 Nov-12-90 */
135 /****************************************************************************/
136 /* bug fix in TRAIN line 1662 change NtrainingPatterns to NTrainingPatterns */
137 /* Thanks to Merrill Flood for pointing out the problem. */
138 /****************************************************************************/
139 /* */
140 /* Changes from Version 1.17 Nov-12-90 to 1.30 Jan-23-91 */
141 /****************************************************************************/
142 /* Added code to allow user to save the weights into and load weights */
143 /* from external files. */
144 /* Added code to allow saving of .net files to save any changes to */
145 /* parameters made during interactive learning trials. */
146 /* Added an alternative main routine that can be used to calculate */
147 /* predictions using a previously saved set of weights. To activate */
148 /* this feature compile the code with the symbol PREDICT_ONLY defined. */
149 /* Added code to allow '# comment' lines in the training or test sets. */
150 /* Added optional code to calculate the number of multiply-accumulates */
151 /* used during training. This is useful for comparing */
152 /* Cascade-correlation to other learning algorithms in a machine */
153 /* independent manner. To activate this feature define the symbol */
154 /* CONNX at compile time. */
155 /* Added code to calculate the Lapedes and Faber Index. Useful for */
156 /* problems with real-valued outputs. */
157 /* Added UnitType VARSIGMOID which can have arbitrary output range */
158 /* defined by SigmoidMin and SigmoidMax. Thanks to Dimitris */
159 /* Michailidis. */
160 /* Added code to allow the training and test data to be read from */
161 /* separate files. Thanks to Carlos Puchol. */
162 /* Added code to save SumError for each output instead of combining it */
163 /* together for all outputs. This change helps for multiple output */
164 /* problems. Thanks to Scott Fahlman. */
165 /* Code added to allow specification of a NonRandomSeed for the random */
166 /* number generator. Thanks to Dimitris Michailidis. */
167 /* Removed useless setting of Ninputs and Noutputs from BUILD_NET. Thanks */
168 /* to Dimitris Michailidis. */
169 /****************************************************************************/
170 /* */
171 /* Changes from Version 1.30 Jan-23-91 to 1.31 Jan-25-91 */
172 /* fixed typo. include <string.h> not <sting.h> thanks to Peter Hancock. */
173 /* */
174 /* Changes from Version 1.31 Jan-25-91 to 1.32 Mar-21-91 */
175 /* BUG FIX in INIT_NET. Thanks to Boris Gokhman */
176 /* BUG FIX in TEST_EPOCH. Thanks to Boris Gokhman */
177 /* */
178 /* Changes from Version 1.32 Mar-21-91 to 1.33 Apr-16-92 */
179 /* Prototype correction for strtok. Thanks to Brian Ripley */
180 /****************************************************************************/
181 //#include "utils.h"
182 
183 #pragma warning(disable:4996)
184 
185 #ifndef INT_MAX
186 #define INT_MAX 32767
187 #endif
188 
189 
190 typedef bool Boolean;
191 
192 #define LINELEN 1024
193 
194 
195 /* switches used in the interface routines */
196 #define INT 0
197 #define FLOAT 1
198 #define ENUM 2 /* integer values that use #defines */
199 #define BOOLE 3
200 #define GETTRAINING 4
201 #define GETTEST 5
202 #define GO 6
203 #define INT_NO 7 /* parameters only good in net-file */
204 #define FLOAT_NO 8 /* most are used in memory allocation */
205 #define ENUM_NO 9 /* and cannot be changed mid-simulation */
206 #define BOOLE_NO 10
207 #define VALUE 11
208 #define GETTRAININGFILE 12
209 #define GETTESTFILE 13
210 #define SAVE 14
211 #define INITFILE 15
212 
213 
214 
215 #define NEXTLINE 0
216 #define FAILURE -1
217 
218 /* switch constants */
219 #define SIGMOID 0
220 #define GAUSSIAN 1
221 #define LINEAR 2
222 #define ASYMSIGMOID 3
223 #define VARSIGMOID 4
224 
225 #define WIN 20
226 #define STAGNANT 21
227 #define TIMEOUT 22
228 #define LOSE 23
229 
230 #define BITS 30
231 #define INDEX 31
232 
233 #define FATAL 0
234 #define WARN 1
235 
236 #define BOMB -99
237 /* Feature types. There are only three types supported (this is
238  a neural network). The logic is ignore,binary otherwise real. */
239 #define REAL 1
240 #define uccIGNORE 2
241 #define BINARY 3
242 
243 #if !defined(min)
244  #define min(X, Y) ((X < Y)?X:Y)
245 #endif
246 
247 #if !defined(max)
248  #define max(X, Y) ((X > Y)?X:Y)
249 #endif
250 
251 #include "KKBaseTypes.h"
252 #include "RunLog.h"
253 #include "XmlStream.h"
254 
255 #include "MLClass.h"
256 #include "FeatureVector.h"
257 
258 
259 namespace KKMLL
260 {
261  #if !defined(_CLASSPROB_)
262  class ClassProb;
263  typedef ClassProb* ClassProbPtr;
264  class ClassProbList;
266  #endif
267 
268 
269  /**
270  *@brief Implementation of Cascade-Correlation network originally written by
271  * R. Scott Crowder, III or CMS restructured as a c++ class.
272  *@details
273  *@code
274  * Important Methods:
275  *
276  * TrainNewClassifier Trains a new classier from training examples.
277  * WriteXML Saves a trained classifier to a output stream in the form of a XML object.
278  * PredictClass Returns back predicted class for a given Feature vector.
279  * PredictClassConfidences Prediction that returns back confidence values for each class rather than a single class prediction.
280  */
281 
282  class UsfCasCor
283  {
284  public:
285  UsfCasCor ();
286 
287  ~UsfCasCor ();
288 
289  kkint32 MemoryConsumedEstimated () const;
290 
291 
292  void TrainNewClassifier (kkint32 _in_limit,
293  kkint32 _out_limit,
294  kkint32 _number_of_rounds,
295  kkint32 _number_of_trials,
296  kkint64 _the_random_seed,
297  bool _useCache,
298  FeatureVectorListPtr _trainData,
299  FeatureNumListConstPtr _selectedFeatures,
300  VolConstBool& _cancelFlag,
301  RunLog& _log
302  );
303 
304  MLClassPtr PredictClass (FeatureVectorPtr example);
305 
306  void PredictConfidences (FeatureVectorPtr example,
307  MLClassPtr knownClass,
308  MLClassPtr& predClass1,
309  float& predClass1Prob,
310  MLClassPtr& predClass2,
311  float& predClass2Prob,
312  float& knownClassProb,
313  const MLClassList& classOrder, /**< Dictates the order in which 'probabilities' will be populated. */
314  VectorFloat& probabilities
315  );
316 
317 
318  ClassProbListPtr PredictClassConfidences (FeatureVectorPtr example);
319 
320 
321  void WriteXML (const KKStr& varName,
322  ostream& o
323  ) const;
324 
325 
326  void ReadXML (XmlStream& s,
327  XmlTagConstPtr tag,
328  VolConstBool& cancelFlag,
329  RunLog& log
330  );
331 
332 
333  private:
334  void CleanUpMemory ();
335 
336  template<typename T>
337  void Delete2DArray (T** &A,
338  kkuint32 numRows
339  );
340 
341 
342  /*****************************************************************************/
343  /* Parameter table contains all user settable parameters. It is used by the */
344  /* input routines to change the values of the named parameters. The list of */
345  /* parameters must be sorted alphabetically so that the search routine will */
346  /* work. Parameter names are used as keywords in the search. Keywords are */
347  /* lower case to speed the comparison process. */
348  /*****************************************************************************/
349  struct parmentry
350  {
351  parmentry (): keyword (NULL), vartype (0), varptr (NULL) {}
352 
353  parmentry (const char* _keyword, int _vartype, void* _varptr):
354  keyword (_keyword), vartype (_vartype), varptr (_varptr)
355  {}
356 
357  const char* keyword; /**< variable name in lower case */
358  int vartype; /**< can be INT, FLOAT, or ENUM */
359  void* varptr; /**< cast to correct type before use */
360  };
361 
362  typedef parmentry PARMS;
363 
364 
365  FeatureVectorListPtr FilterOutExtremeExamples (FeatureVectorListPtr trainExamples);
366 
367 
368  /* Global variables */
369  static const char* version;
370  static const char* release_date;
371  static const char* progname;
372 
373  char const * boolean_to_string (bool var) const;
374 
375  Boolean string_to_boolean (const char* s);
376 
377  const KKStr& type_to_string (int var) const;
378 
379  int string_to_type (const KKStr& s);
380 
381  /* Utilities */
382 
383  void INITIALIZE_GLOBALS ();
384 
385 
386 
387  //***************************************************************
388  //* usfcascor *
389  //***************************************************************
390  int in_limit;
391  int out_limit;
392  int number_of_trials;
393  int number_of_rounds;
394  int normalization_method;
395  int my_mpi_rank;
396 
397  void setup_network (FeatureVectorListPtr trainExamples,
398  RunLog& log
399  );
400 
401  void train_network (VolConstBool& cancelFlag,
402  RunLog& log
403  );
404 
405  void allocate_network (RunLog& log);
406 
407 
408  //****************************************************************
409  //* 'parms.c' *
410  //****************************************************************
411  static const KKStr type_strings[];
412  static const char* boolean_strings[2];
413 
414  char parm_string[LINELEN];
415 
416  void strdncase (char *s);
417 
418  int _type_convert (char *input);
419 
420  Boolean _boolean_convert (char *input);
421 
422 
423 
424 
425  //**********************************************************************************
426  //* util.c *
427  //**********************************************************************************
428  float random_weight ();
429 
430 
431  //******************************************************************************************
432  //* load_namesfile.c *
433  //******************************************************************************************
434  void load_namesfile (FeatureVectorListPtr trainExamples,
435  FeatureNumListConstPtr selectedFeatures
436  );
437 
438 
439 
440 
441  //******************************************************************************************
442  //* learn.c *
443  //******************************************************************************************
444  int ErrorMisclassifications;
445 
446  float ACTIVATION (float sum);
447 
448  float ACTIVATION_PRIME (float value,
449  float sum
450  );
451 
452  float OUTPUT_FUNCTION (float sum);
453 
454  float OUTPUT_PRIME (float output);
455 
456  void QUICKPROP_UPDATE (int i,
457  float weights[],
458  float deltas[],
459  float slopes[],
460  float prevs[],
461  float epsilon,
462  float decay,
463  float mu,
464  float shrink_factor
465  );
466 
467  void SETUP_INPUTS (float inputs[]);
468 
469  void OUTPUT_FORWARD_PASS ();
470 
471  void COMPUTE_UNIT_VALUE (int j);
472 
473  void FULL_FORWARD_PASS (float input[]);
474 
475 
476  void COMPUTE_ERRORS (float goal[],
477  Boolean output_slopesp,
478  Boolean statsp,
479  int xw
480  );
481 
482  void UPDATE_OUTPUT_WEIGHTS ();
483 
484 
485  void TRAIN_OUTPUTS_EPOCH ();
486 
487  int TRAIN_OUTPUTS (int max_epochs,
488  VolConstBool& cancelFlag
489  );
490 
491  void INIT_CANDIDATES ();
492 
493  void INSTALL_NEW_UNIT (RunLog& log);
494 
495  void COMPUTE_CORRELATIONS ();
496 
497  void ADJUST_CORRELATIONS ();
498 
499  void COMPUTE_SLOPES ();
500 
501  void UPDATE_INPUT_WEIGHTS ();
502 
503  void TRAIN_INPUTS_EPOCH ();
504 
505  void CORRELATIONS_EPOCH ();
506 
507  int TRAIN_INPUTS (int max_epochs);
508 
509  void LIST_PARAMETERS ();
510 
511  int TRAIN (int outlimit,
512  int inlimit,
513  int rounds,
514  VolConstBool& cancelFlag,
515  RunLog& log
516  );
517 
518  void TEST_EPOCH (double test_threshold,
519  RunLog& log
520  );
521 
522  void OUT_PASS_OUTPUT ();
523 
524  KKStr PRINT_SUMMARY (int n);
525 
526  void initialize_network ();
527 
528  float STANDARD_DEV (float** outputs,
529  int npatterns,
530  int nvalues
531  );
532 
533 
534  float ERROR_INDEX (double std_dev,
535  int num
536  );
537 
538 
539  //******************************************************************
540  //* load_data.c *
541  //******************************************************************
542 
543 
544  void load_data (FeatureVectorListPtr trainExamples,
545  RunLog& log
546  );
547 
548  void _load_training_data (FeatureVectorListPtr trainExamples);
549 
550  void _load_training_example (FeatureVectorPtr example,
551  int i
552  );
553 
554 
555  void _load_test_data (FeatureVectorPtr example);
556 
557 
558 
559  //******************************************************************************
560  // globals.c *
561  //******************************************************************************
562  int number_of_classes;
563  char* filestem;
564  int line_length;
565  int* feature_type;
566 
567  kkint64 the_random_seed;
568 
569 
570  /* Flags */
571  Boolean load_weights;
572 
573 
574  int UnitType; /**< hidden unit type can be SIGMOID or GAUSIAN*/
575  int OutputType; /**< output unit type can be SIGMOID or LINEAR */
576 
577  float SigmoidMax; /**< Maximum output value for sigmoid units. Used to alter sigmoid range without having to edit *
578  * training values. Use the symbols "min" and "max" in the input file. The input routines *
579  * will translate to the appropriate float values.
580  */
581 
582  float SigmoidMin; /**< Minimum output value for sigmoid units. */
583  float WeightRange; /**< Random-init weights in range [-WR,+WR] */
584  float SigmoidPrimeOffset; /**< Add to sigmoid-prime to kill flat spots */
585  float WeightMultiplier; /**< Scale Candidate correlation to get init weight */
586  float OutputMu; /**< Mu used to quickprop train output weights. */
587  float OutputShrinkFactor; /**< Used in computing whether the proposed step is too large. Related to OutputMu. */
588  float OutputEpsilon; /**< Controls the amount of linear gradient descent to use in updating output weights. */
589 
590  float OutputDecay; /**< This factor times the current weight is added to the slope at the start of each
591  * output epoch Keeps weights from growing too big.
592  */
593 
594  int OutputPatience; /**< If we go for this many epochs with no real change, it's time to stop tuning.
595  * If 0, go on forever.
596  */
597 
598  float OutputChangeThreshold; /**< The error must change by at least this fraction of its old value to count as a significant change. */
599  float InputMu; /**< Mu used to quick prop train input weights. */
600  float InputShrinkFactor; /**< Used in computing whether the proposed step is too large. Related to InputMu. */
601  float InputEpsilon; /**< Controls the amount of linear gradient descent to use in updating Input weights. */
602  float InputDecay; /* This factor times the current weight is added to the slope at the start of each Input epoch *
603  * Keeps weights from growing too big. */
604 
605  int InputPatience; /* If we go for this many epochs with no real change, it's time to stop tuning. If 0,
606  * go on forever. */
607 
608  float InputChangeThreshold; /* The error must change by at least this fraction of its old value to count as a significant change. */
609 
610  /* Variables related to error and correlation. */
611  float TrueError; /**< Total output error for one epoch */
612  float ScoreThreshold; /**< This close to desired value => bit is correct */
613  int ErrorBits; /**< Total # bits in epoch that were wrong */
614 
615  float* SumErrors; /**< Accumulate the sum of the error values used in the correlation phase.
616  * Sum is stored separately for each output. Values are converted to
617  * average errors before use in ADJUST_CORRELATION
618  */
619 
620  float* DummySumErrors; /**< Replace SumErrors with this for test epochs. */
621  float SumSqError; /**< Accumulate the sum of the square of the error values used in the correlation phase.*/
622  float BestCandidateScore; /**< Best correlation score of all candidate units. */
623  int BestCandidate; /**< Index of the candidate unit with best score. */
624  Boolean UseCache; /**< If TRUE, cache the forward-pass values instead of repeatedly computing them. */
625  int Epoch; /**< Current epoch number */
626  Boolean Graphics; /**< If TRUE, print progress after each epoch. */
627  Boolean NonRandomSeed; /**< TRUE => use 1 as the seed for the random number generator. Useful when comparing
628  * different parameter settings. FALSE => use system clock to start random sequence.
629  */
630 
631  Boolean Test; /**< If TRUE, run a test epoch and print the result after each round of output tuning. */
632 
633  Boolean SinglePass; /**< TRUE => Pause after forward/backward cycle */
634  Boolean SingleEpoch; /**< TRUE => Pause after each training epoch */
635  Boolean Step; /**< Turned to TRUE after each pause, briefly */
636  int Trial; /**< Current trial number, used in log outputs */
637 
638 
639  /* The sets of training inputs and outputs. */
640  int NTrainingPatterns; /**< !! Not in Lisp version. Needed here. */
641  int NTestPatterns; /**< !! Not in Lisp version. Needed here. */
642  float** TrainingInputs;
643  float** TrainingOutputs;
644  float* Goal; /**< Goal vector for the current training or testing case. */
645 
646  float* example_weight;
647 
648  /* For some benchmarks there is a separate set of values used for testing */
649  /* the network's ability to generalize. These values are not used during */
650  /* training. */
651  float** TestInputs;
652  float** TestOutputs;
653 
654 
655  /***************************************************************************/
656  /* Fundamental data structures. */
657  /* */
658  /* Unit outputs and weights are floats. */
659  /* */
660  /* Instead of representing each unit by a structure, we represent the */
661  /* unit by a int. This is used to index into various arrays that hold */
662  /* per-unit information, such as the activation value of each unit. */
663  /* */
664  /* Per-connection information for each connection COMING INTO unit is */
665  /* stored in a array of arrays. The outer array is indexed by the unit */
666  /* number, and the inner array is then indexed by connection number. */
667  /* */
668  /* Unit 0 is always at a maximum-on value. Connections from this unit */
669  /* supply a bias. Next come some input units, then some hidden units. */
670  /* */
671  /* Output units have their own separate set of data structures, as do */
672  /* candidate units whose inputs are currently being trained. */
673  /***************************************************************************/
674  int MaxUnits; /**< Maximum number of input values and hidden in the network. */
675  int Nunits; /**< Total number of active units in net */
676  int Ninputs; /**< Number of input units */
677  int Noutputs; /**< Number of output units */
678  int Ncandidates; /**< Number of candidate units trained at once. */
679  int MaxCases; /**< Maxi mum number of training cases that can be accommodated by the current data structures. */
680  int Ncases; /**< Number of training cases currently in use. Assume a contiguous block beginning with */
681  int FirstCase; /**< Address of the first training case in the currently active set. Usually zero, but may
682  * differ if we are training on different chunks of the training set at different times.
683  */
684 
685 
686  /***************************************************************************/
687  /* The following vectors hold values related to hidden units in the active */
688  /* net and their input weights. */
689  /***************************************************************************/
690  float* Values; /**< Current activation value for each unit */
691  float** ValuesCache; /**< Holds a distinct Values array for each of the MaxCases training cases. */
692  float* ExtraValues; /**< Extra Values vector to use when no cache. */
693  int* Nconnections; /**< # of INCOMING connections per unit */
694  int** Connections; /**< C[i][j] lists jth unit projecting to unit i */
695  float** Weights; /**< W[i][j] holds weight of C[i][j] */
696 
697  /***************************************************************************/
698  /* The following arrays of arrays hold values for the outputs of the active*/
699  /* network and the output-side weights. */
700  /***************************************************************************/
701  float* Outputs; /**< Network output values */
702  float* Errors; /**< Final error value for each unit */
703  float** ErrorsCache; /**< Holds a distinct Errors array for each of the MaxCases training cases. */
704  float* ExtraErrors; /**< Extra Errors vector to use when no cache. */
705  float** OutputWeights; /**< OW[i][j] holds the weight from hidden unit i to output unit j */
706  float** OutputDeltas; /**< Change between previous OW and current one */
707  float** OutputSlopes; /**< Partial derivative of TotalError wrt OW[i][j] */
708  float** OutputPrevSlopes; /**< Previous value of OutputSlopes[i][j] */
709 
710  /***************************************************************************/
711  /* The following arrays have one entry for each candidate unit in the */
712  /* pool of trainees. */
713  /***************************************************************************/
714  float* CandValues; /**< Current output value of each candidate unit. */
715  float* CandSumValues; /**< Output value of each candidate unit, summed over an entire training set. */
716  float** CandCor; /**< Correlation between unit & residual error at each output, computed over a whole epoch. */
717  float** CandPrevCor; /**< Holds the CandCor values from last epoch. */
718  float** CandWeights; /**< Current input weights for each candidate unit. */
719  float** CandDeltas; /**< Input weights deltas for each candidate unit. */
720  float** CandSlopes; /**< Input weights slopes for each candidate unit. */
721  float** CandPrevSlopes; /**< Holds the previous values of CandSlopes. */
722 
723  /***************************************************************************/
724  /* This saves memory if each candidate unit receives a connection from */
725  /* each existing unit and input. That's always true at present, but may */
726  /* not be in future. */
727  /***************************************************************************/
728  int* AllConnections; /**< A standard connection that connects a unit to all previous units, in order, but not to the bias unit. */
729 
730  /***************************************************************************/
731  /* ErrorIndex specific globals. Not in release Lisp version */
732  /***************************************************************************/
733  int NtrainingOutputValues; /**< Number of outputs in the training set. */
734  int NtestOutputValues; /**< Number of outputs in the test set. */
735  float TrainingStdDev; /**< Std Dev of entire training set. Used to normalize the ErrorIndex. */
736  float TestStdDev;
737  float ErrorIndex; /**< Normalized error function for continuous output training sets. */
738  float ErrorIndexThreshold; /**< Stop training when ErrorIndex is < EIT. */
739  int ErrorMeasure; /**< Set to BITS for using ErrorBits to stop of INDEX to use ErrorIndex to stop. */
740 
741  /***************************************************************************/
742  /* Save and plot file related variables */
743  /***************************************************************************/
744  FILE* WeightFile; /**< Contains weights from the current net. */
745 
746  Boolean InterruptPending; /**< TRUE => user has pressed Control-C */
747 
748  MLClassListPtr classes; /**< Classes that the training data consisted of. */
749 
750  FeatureNumListPtr selectedFeatures; /**< The selected features that are to be used from the source training data. */
751  }; /* UsfCasCor */
752 
753  typedef UsfCasCor* UsfCasCorPtr;
754 
755 
756  typedef XmlElementTemplate<UsfCasCor> XmlElementUsfCasCor;
757  typedef XmlElementUsfCasCor* XmlElementUsfCasCorPtr;
758 
759 
760 
761 
762 } /* KKMLL */
763 
764 #endif
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
__int64 kkint64
Definition: KKBaseTypes.h:90
#define LINELEN
Definition: UsfCasCor.h:192
FeatureNumList * FeatureNumListPtr
XmlTag const * XmlTagConstPtr
Definition: KKStr.h:45
std::vector< float > VectorFloat
Definition: KKBaseTypes.h:149
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
Definition: XmlStream.h:46
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
FeatureNumListConst * FeatureNumListConstPtr
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
Maintains a list of MLClass instances.
Definition: MLClass.h:233
#define INT_MAX
Adapted by Kurt Kramer be a &#39;class&#39; definition so as to make it more usable in th ePices software wor...
Definition: UsfCasCor.h:186
bool Boolean
Definition: UsfCasCor.h:190
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163