00001 #ifndef CGENERALNEURON_H 00002 #define CGENERALNEURON_H 00003 #include "GeneralLinearCombiner.h" 00004 00005 namespace gplib 00006 { 00007 /** \addtogroup neuralnet Neural Network filtering */ 00008 /* @{ */ 00009 00010 //! The base class for all neurons in a neural network 00011 00012 /*! GeneralNeuron implements some common functionality, but mostly abstract base classes 00013 * to define a common interface for all neurons*/ 00014 class GeneralNeuron 00015 { 00016 private: 00017 //! We have to store the last output, because during adaption stage the weights might be changed but we want the original value 00018 double LastOutput; 00019 //! The function that calculates the output of the neuron, has to be overriden and is executed by GetOutput in this class 00020 virtual double CalcOutput() = 0; 00021 public: 00022 //! Calculate the derivative of the activation function, at point input 00023 virtual double CalcDeriv(const double input) = 0; 00024 //! Get the net output before application of the activation function 00025 virtual double GetNet() = 0; 00026 //! Get delta for the weight correction formula 00027 virtual double GetDelta() = 0; 00028 //! Set delta 00029 virtual void SetDelta(const double d) = 0; 00030 //! Set the bias 00031 virtual void SetBias(const double b) = 0; 00032 //! Get the bias 00033 virtual double GetBias() = 0; 00034 //! Access function for the weights 00035 virtual const std::vector<double> &GetWeights() = 0; 00036 virtual std::vector<double> &SetWeights() = 0; 00037 //! Vector valued delta for the momentum adaptation scheme 00038 virtual const std::vector<double> &GetOldDelta() = 0; 00039 virtual std::vector<double> &SetOldDelta() = 0; 00040 //! Get the pointers to the input neurons 00041 virtual const GeneralLinearCombiner::tinvector &GetInput() = 0; 00042 //! Get the output given the current weights 00043 double GetOutput() 00044 { 00045 LastOutput = CalcOutput(); 00046 return LastOutput; 00047 } 00048 //! Get the last result from calling GetOutput, needed during adaptation 00049 double GetLastOutput() 00050 { 00051 return LastOutput; 00052 } 00053 //! Set pointers to the input 00054 virtual void SetInput(const GeneralLinearCombiner::tinvector &input) 00055 { 00056 } 00057 GeneralNeuron() 00058 { 00059 } 00060 virtual ~GeneralNeuron() 00061 { 00062 } 00063 }; 00064 /* @} */ 00065 } 00066 #endif // CGENERALNEURON_H
1.5.8