//Weight.h // //class interface for weighted links between nodes in neural networks // //The weighted links describe connections between nodes, and contain: // a pointer to the node that this node is connected to; // the weight of the connection; and, // the last change in the connection weight (useful in network training). // //Typically, this class will be used only by the Node class and its subclasses. // // //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 WEIGHT_H #define WEIGHT_H template class Node; template class Weight { public: //-----------readers and writers------------- weightType readWeight (); void writeWeight (weightType value); weightType readWeightChange (); void writeWeightChange (weightType value); Node* readNodePointer (); void writeNodePointer (Node *node); //-----------randomization function----------- //sets weight to a random value of: //for integer types (bool, short, int): 0 or 1 //for floating point types: a value between 1 and -1 void randomizeWeight(); private: weightType weight; weightType lastWeightChange; Node *nodePointer; }; #endif