///////////////////////////////////////////////////////////////////////////// // // class Neuron // // this is an implementation of one neuron of a Neural Network // so this neuron has a Weight-Matrix IW and a bias vector b1 // this neuron can have n input values, but only one output value // (see NeuralNet documentations for more information) // // header file // // Copyright (c) 2005 Georg Holzmann // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // ///////////////////////////////////////////////////////////////////////////// #ifndef _INCLUDE_NEURON_NET__ #define _INCLUDE_NEURON_NET__ #include #include #include "NNException.h" #include "m_pd.h" //debug namespace TheBrain { //------------------------------------------------------ /* class of one neuron */ class Neuron { protected: /* this is the number of input values, which is * automatically the input and the size of IW */ int inputs_; /* the input weight matrix IW * (size: inputs ) */ float *IW_; /* the bias vector b1 */ float b1_; /* the learning rate of the net */ float learn_rate_; /* the range of the input values should be from 0 * to range_ * outputvalues are from -1 to 1 */ float range_; public: /* Constructor */ Neuron(int inputs, int dummy=0); /* Destructor */ virtual ~Neuron(); //----------------------------------------------------- /* Set/Get learning rate */ virtual void setLearningRate(float learn_rate) { learn_rate_=learn_rate; } virtual float getLearningRate() const { return learn_rate_; } /* Set/Get range */ virtual void setRange(float range) { range_=range; } virtual float getRange() const { return range_; } /* some more get/set methods */ virtual int getInputs() const { return inputs_; } virtual float *getIW() const { return IW_; } virtual float getIW(int index) const { return IW_[index]; } virtual void setIW(const float *IW) { for(int i=0; i