GPLIB++
GeneralLinearCombiner.h
Go to the documentation of this file.
1 #ifndef CGENERALLINEARCOMBINER_H
2 #define CGENERALLINEARCOMBINER_H
3 #include <vector>
4 #include <boost/shared_ptr.hpp>
5 
6 namespace gplib
7  {
8  class GeneralNeuron;
9 
10  /** \addtogroup neuralnet Neural Network filtering */
11  /* @{ */
12 
13  //! A linear combiner as a component of a neural network
14  /*! It can cache the last output for faster calculation within the network, but this assumes that between every output calculation
15  the weights are updated.
16  */
18  {
19  public:
20  typedef std::vector<boost::shared_ptr<GeneralNeuron> > tinvector;
21  private:
22  //! The weight for each input channel
23  std::vector<double> Weights;
24  //! The current output
25  double Output;
26  //! A vector of pointers to other neurons, that provide the input for this combiner
27  tinvector Input;
28  //! The bias weight
29  double Bias;
30  //! have the weights changed since the last calculation ?
31  bool wchanged;
32  //! has the bias changed since the last calculation ?
33  bool bchanged;
34  //! do we want to cache the output or recalculate it every time
35  bool cachedoutput;
36  public:
37  //! Set the bias weigth
38  void SetBias(const double b)
39  {
40  bchanged = true;
41  Bias = b;
42  }
43  //! Get the current value for the bias
44  double GetBias() const
45  {
46  return Bias;
47  }
48  //! Get the values of the Weight vector
49  const std::vector<double> &GetWeights() const
50  {
51  return Weights;
52  }
53  //! change the values of the Weight vector
54  std::vector<double> &SetWeights()
55  {
56  wchanged = true;
57  return Weights;
58  }
59  //! Calculate the output given the current configuration
60  virtual double CalcOutput();
61  //! connect the input channels to the neurons given in LocalInput
62  virtual void SetInput(const tinvector &LocalInput);
63  //! get the input channel configuration
64  const tinvector &GetInput() const
65  {
66  return Input;
67  }
68  explicit GeneralLinearCombiner(bool wantcached = false);
69  virtual ~GeneralLinearCombiner();
70  };
71  /* @} */
72  }
73 #endif // CGENERALLINEARCOMBINER_H
const std::vector< double > & GetWeights() const
Get the values of the Weight vector.
GeneralLinearCombiner(bool wantcached=false)
double GetBias() const
Get the current value for the bias.
virtual void SetInput(const tinvector &LocalInput)
connect the input channels to the neurons given in LocalInput
void SetBias(const double b)
Set the bias weigth.
virtual double CalcOutput()
Calculate the output given the current configuration.
std::vector< double > & SetWeights()
change the values of the Weight vector
A linear combiner as a component of a neural network.
std::vector< boost::shared_ptr< GeneralNeuron > > tinvector
const tinvector & GetInput() const
get the input channel configuration