SigmoidalNeuron.h
Go to the documentation of this file.00001 #ifndef CSIGMOIDALNEURON_H
00002 #define CSIGMOIDALNEURON_H
00003 #include "GeneralLinearCombiner.h"
00004 #include "GeneralActivationFunction.h"
00005 #include "GeneralNeuron.h"
00006 #include <vector>
00007 #include <boost/shared_ptr.hpp>
00008 #include <boost/function.hpp>
00009
00010 namespace gplib
00011 {
00012
00013
00014
00015
00016 class SigmoidalNeuron: public GeneralNeuron
00017 {
00018 public:
00019
00020 enum tneurontype
00021 {
00022 bipolar, identity
00023 };
00024 private:
00025
00026 std::vector<double> OldDelta;
00027
00028 boost::shared_ptr<GeneralLinearCombiner> Combiner;
00029
00030 boost::shared_ptr<GeneralActivationFunction> Function;
00031
00032 double Output;
00033
00034 double Delta;
00035
00036 double Net;
00037
00038 bool cachedoutput;
00039
00040 virtual double CalcOutput();
00041 public:
00042
00043 virtual const std::vector<double> &GetOldDelta()
00044 {
00045 return OldDelta;
00046 }
00047 virtual std::vector<double> &SetOldDelta()
00048 {
00049 return OldDelta;
00050 }
00051
00052 virtual double CalcDeriv(const double input)
00053 {
00054 return Function->CalcDeriv(input);
00055 }
00056
00057 virtual double GetNet()
00058 {
00059 return Net;
00060 }
00061
00062 virtual double GetDelta()
00063 {
00064 return Delta;
00065 }
00066
00067 virtual void SetDelta(const double d)
00068 {
00069 Delta = d;
00070 }
00071
00072 virtual void SetBias(const double b)
00073 {
00074 Combiner->SetBias(b);
00075 }
00076
00077 virtual double GetBias()
00078 {
00079 return Combiner->GetBias();
00080 }
00081
00082 virtual const std::vector<double> &GetWeights()
00083 {
00084 return Combiner->GetWeights();
00085 }
00086
00087 virtual std::vector<double> &SetWeights()
00088 {
00089 return Combiner->SetWeights();
00090 }
00091
00092 virtual const GeneralLinearCombiner::tinvector &GetInput()
00093 {
00094 return Combiner->GetInput();
00095 }
00096
00097 virtual void SetInput(const GeneralLinearCombiner::tinvector &input);
00098
00099 virtual void SetType(tneurontype type);
00100
00101 explicit SigmoidalNeuron(tneurontype type, bool wantcached = false);
00102 virtual ~SigmoidalNeuron();
00103 };
00104
00105 }
00106 #endif // CSIGMOIDALNEURON_H