GPLIB++
GeneralNeuron.h
Go to the documentation of this file.
1 #ifndef CGENERALNEURON_H
2 #define CGENERALNEURON_H
4 
5 namespace gplib
6  {
7  /** \addtogroup neuralnet Neural Network filtering */
8  /* @{ */
9 
10  //! The base class for all neurons in a neural network
11 
12  /*! GeneralNeuron implements some common functionality, but mostly abstract base classes
13  * to define a common interface for all neurons*/
15  {
16  private:
17  //! We have to store the last output, because during adaption stage the weights might be changed but we want the original value
18  double LastOutput;
19  //! The function that calculates the output of the neuron, has to be overriden and is executed by GetOutput in this class
20  virtual double CalcOutput() = 0;
21  public:
22  //! Calculate the derivative of the activation function, at point input
23  virtual double CalcDeriv(const double input) = 0;
24  //! Get the net output before application of the activation function
25  virtual double GetNet() = 0;
26  //! Get delta for the weight correction formula
27  virtual double GetDelta() = 0;
28  //! Set delta
29  virtual void SetDelta(const double d) = 0;
30  //! Set the bias
31  virtual void SetBias(const double b) = 0;
32  //! Get the bias
33  virtual double GetBias() = 0;
34  //! Access function for the weights
35  virtual const std::vector<double> &GetWeights() = 0;
36  virtual std::vector<double> &SetWeights() = 0;
37  //! Vector valued delta for the momentum adaptation scheme
38  virtual const std::vector<double> &GetOldDelta() = 0;
39  virtual std::vector<double> &SetOldDelta() = 0;
40  //! Get the pointers to the input neurons
41  virtual const GeneralLinearCombiner::tinvector &GetInput() = 0;
42  //! Get the output given the current weights
43  double GetOutput()
44  {
45  LastOutput = CalcOutput();
46  return LastOutput;
47  }
48  //! Get the last result from calling GetOutput, needed during adaptation
49  double GetLastOutput()
50  {
51  return LastOutput;
52  }
53  //! Set pointers to the input
54  virtual void SetInput(const GeneralLinearCombiner::tinvector &input)
55  {
56  }
58  {
59  }
60  virtual ~GeneralNeuron()
61  {
62  }
63  };
64  /* @} */
65  }
66 #endif // CGENERALNEURON_H
virtual void SetInput(const GeneralLinearCombiner::tinvector &input)
Set pointers to the input.
Definition: GeneralNeuron.h:54
double GetOutput()
Get the output given the current weights.
Definition: GeneralNeuron.h:43
virtual double GetNet()=0
Get the net output before application of the activation function.
virtual const std::vector< double > & GetOldDelta()=0
Vector valued delta for the momentum adaptation scheme.
virtual double GetDelta()=0
Get delta for the weight correction formula.
virtual std::vector< double > & SetWeights()=0
virtual double GetBias()=0
Get the bias.
virtual std::vector< double > & SetOldDelta()=0
virtual void SetBias(const double b)=0
Set the bias.
double GetLastOutput()
Get the last result from calling GetOutput, needed during adaptation.
Definition: GeneralNeuron.h:49
The base class for all neurons in a neural network.
Definition: GeneralNeuron.h:14
virtual void SetDelta(const double d)=0
Set delta.
virtual const GeneralLinearCombiner::tinvector & GetInput()=0
Get the pointers to the input neurons.
virtual double CalcDeriv(const double input)=0
Calculate the derivative of the activation function, at point input.
virtual ~GeneralNeuron()
Definition: GeneralNeuron.h:60
virtual const std::vector< double > & GetWeights()=0
Access function for the weights.
std::vector< boost::shared_ptr< GeneralNeuron > > tinvector