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

Generated on Fri Jul 4 15:30:20 2008 for GPLIB++ by  doxygen 1.5.5