Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Neuron.h

Go to the documentation of this file.
00001 #ifndef _NEURON_H
00002 #define _NEURON_H
00003 
00004 #include "Link.h"
00005 #include "defines.h"
00006 #include <string>
00007 
00008 namespace annie
00009 {
00010 
00011 // Some activation functions and their derivatives
00012 
00014 real identity(real x);
00016 real didentity(real x);
00018 real sigmoid(real x);
00020 real dsigmoid(real x);
00022 real gaussian(real x);
00024 real dgaussian(real x);
00032 real signum(real x);
00034 real tansig(real x);
00036 real dtansig(real x);
00037 
00039 real random();
00040 
00042 real random2();
00043 
00049 int randomInt(int low, int high);
00050 
00052 
00058 typedef real(*ActivationFunction)(real);
00059 
00061 typedef std::vector<Link *> LINKS;
00062 
00086 class Neuron
00087 {
00088 protected:
00090         int _label;
00091 
00097         bool _outputCacheValid;
00098 
00100         real _activationCache;
00102         real _outputCache;
00103 
00105         bool _errorCacheValid;
00107         real _errorCache;
00108 
00118         std::vector<char *> _classHeirarchy;
00119 
00121         LINKS _inputLinks;
00122 public:
00127         LINKS _outputLinks;
00128 protected:
00130         ActivationFunction _activationFunction;
00131         
00149         virtual void _recacheOutput()=0;
00150 
00166         virtual void _recacheError()=0;
00167         
00168 public:
00172         Neuron(int label);
00173 
00174         Neuron(Neuron &neuron);
00175 
00177         virtual ~Neuron();
00178 
00185         virtual real getActivation();
00186         
00192         virtual real getOutput();
00193 
00199         virtual real getError();
00200         
00202         virtual int getLabel();
00203 
00207         virtual int getInputCount();
00208 
00212         virtual int getOutputCount();
00213 
00220         virtual void invalidateOutputCache();
00221 
00226         virtual void invalidateErrorCache();
00227 
00234         virtual int getInputs(std::vector<int> &labels, VECTOR &weights);
00235 
00240         virtual void disconnect(Neuron *from);
00241 
00247         virtual real getWeight(Neuron *from);
00248 
00253         virtual std::string toString();
00254         
00258         virtual const char *getClassName()=0;
00259         friend class Link;
00260 
00275         bool instanceOf(const char *className);
00276 
00281         friend std::ostream& operator << (std::ostream& s, Neuron &neuron);
00282 };
00283 
00284 }; //namespace annie
00285 #endif // define _NEURON_H
00286 

Generated on Wed Apr 23 10:42:34 2003 for BioFilter by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002