//FeedforwardNode.h // //Declaration of abstract base class for feedforward neural network nodes. //FeedforwardNode inherits functionality from the abstract Node 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 FEEDFN_H #define FEEDFN_H #include "Node.cpp" class FeedforwardNode : public Node { public: FeedforwardNode (); //copy constructor FeedforwardNode (const FeedforwardNode &fnode); //assignment operator FeedforwardNode& operator= (const FeedforwardNode &fnode); //--------------calculation of the node activation--------------- //"Activation" calculates the net input of the nodes, and then calls "ActivationFunction." //The threshold has a default value of zero, and so need not be entered. // double activation (double threshold); //"firstHiddenLayerActivation" acts on an array of input values (*inputVector), rather than on the outputs of // any lower level nodes, and is useful when there are multiple input patterns. //The threshold variable has a default value of zero. // double firstHiddenLayerActivation (double *inputVector, double threshold); //ActivationFunction uses a logistic function (1/(1+e^-(net-threshold)) to calculate the output of the node; // overload this to use a different function (e.g., a lookup-table-based function for speed). double activationFunction (double net, double threshold); //-------------error calculation functions------------ //These pure virtual functions are for use by derived classes for network evaluation/training. //Calculate the error of a node. //For hidden layer nodes, this function will assign responsibility for the error in the output nodes. virtual double calculateError () = 0; //Calculate the error of an output node. virtual double calculateOutputNodeError (double actualValue) = 0; //------------------readers and writers-------------------------- //Read the error in the node output. CAREFUL: the stored value may not be updated. double readError(); protected: double error; }; #endif