//BackpropagationNode.h // //This file declares a BackpropagationNode class for use in training feedforward //artificial neural networks using backpropagation of errors // //The BackpropagationNode class extends the FeedforwardNode abstract base class. // // //Copyright 1998 Michael J. Wax //You may use this code as is, or incorporate it in another program, //as long as proper attribution is given. However, I make no warranties, //express or implied, regarding the performance of this code, its freedom from //error, or its suitability for use in a given application. //Questions or suggestions? Contact me at neural@michaelwax.com // #ifndef BNODE_H #define BNODE_H #include "FeedforwardNode.cpp" //class declarations class BackpropagationNode : public FeedforwardNode { public: BackpropagationNode (); //------------errror calculation functions-------------------- //These functions calculate and return the error in the output value of the node. //Because they also alter the stored node error value, you can ignore the return value. //For all except output layer nodes: calculate the error based on backpropagation of error from the output nodes. double calculateError (); //For output layer nodes: calculate the error based on the difference between the calculated and actual values. double calculateOutputNodeError (double actualValue); //------------weight adjustment functions------------------------- //These adjust the input weights to minimize the error in the output, and save the change in weights. //Eta limits the amount of change in the weights during a given iteration, and has a default value of 0.5. //Alpha, the momentum parameter, determines how much of the last weight change // is added to the current calculated weight change, and has a default value of 0.5. //For all except first hidden layer nodes. //For output nodes, an eta of 0.3 might be better than the default of 0.5. void adjustWeight (double eta, double alpha); //For first hidden layer nodes when we have multiple input patterns not stored as input nodes. //If many hidden layers, etas higher than 0.5 might be better. void adjustFirstHiddenLayerNodeWeight (double *inputVector, double eta, double alpha); }; #endif