GeneralLinearCombiner.h

Go to the documentation of this file.
00001 #ifndef CGENERALLINEARCOMBINER_H
00002 #define CGENERALLINEARCOMBINER_H
00003 #include <vector>
00004 #include <boost/shared_ptr.hpp>
00005 
00006 namespace gplib
00007   {
00008     class GeneralNeuron;
00009 
00010     /** \addtogroup neuralnet Neural Network filtering */
00011     /* @{ */
00012 
00013     //! A linear combiner as a component of a neural network
00014     /*! It can cache the last output for faster calculation within the network, but this assumes that between every output calculation
00015      the weights are updated.
00016      */
00017     class GeneralLinearCombiner
00018       {
00019     public:
00020       typedef std::vector<boost::shared_ptr<GeneralNeuron> > tinvector;
00021     private:
00022       //! The weight for each input channel
00023       std::vector<double> Weights;
00024       //! The current output
00025       double Output;
00026       //! A vector of pointers to other neurons, that provide the input for this combiner
00027       tinvector Input;
00028       //! The bias weight
00029       double Bias;
00030       //! have the weights changed since the last calculation ?
00031       bool wchanged;
00032       //! has the bias changed since the last calculation ?
00033       bool bchanged;
00034       //! do we want to cache the output or recalculate it every time
00035       bool cachedoutput;
00036     public:
00037       //! Set the bias weigth
00038       void SetBias(const double b)
00039         {
00040           bchanged = true;
00041           Bias = b;
00042         }
00043       //! Get the current value for the bias
00044       double GetBias() const
00045         {
00046           return Bias;
00047         }
00048       //! Get the values of the Weight vector
00049       const std::vector<double> &GetWeights() const
00050         {
00051           return Weights;
00052         }
00053       //! change the values of the Weight vector
00054       std::vector<double> &SetWeights()
00055         {
00056           wchanged = true;
00057           return Weights;
00058         }
00059       //! Calculate the output given the current configuration
00060       virtual double CalcOutput();
00061       //! connect the input channels to the neurons given in LocalInput
00062       virtual void SetInput(const tinvector &LocalInput);
00063       //! get the input channel configuration
00064       const tinvector &GetInput() const
00065         {
00066           return Input;
00067         }
00068       explicit GeneralLinearCombiner(bool wantcached = false);
00069       virtual ~GeneralLinearCombiner();
00070       };
00071   /* @} */
00072   }
00073 #endif // CGENERALLINEARCOMBINER_H

Generated on Tue May 4 16:52:14 2010 for GPLIB++ by  doxygen 1.5.8