NeuralNetwork.h
Go to the documentation of this file.00001 #ifndef CNEURALNETWORK_H
00002 #define CNEURALNETWORK_H
00003 #include <vector>
00004 #include <iostream>
00005 #include <boost/shared_ptr.hpp>
00006 #include "SigmoidalNeuron.h"
00007 #include "InputNeuron.h"
00008 #include "AdaptiveFilter.h"
00009
00010 namespace gplib
00011 {
00012
00013
00014
00015
00016
00017 class NeuralNetwork: public AdaptiveFilter
00018 {
00019 public:
00020 typedef std::vector<boost::shared_ptr<GeneralNeuron> > tNeuralLayer;
00021 typedef std::vector<tNeuralLayer> tNeuralArray;
00022 typedef std::vector<SigmoidalNeuron::tneurontype> ttypeVector;
00023 typedef std::vector<ttypeVector> ttypeArray;
00024 private:
00025
00026 std::vector<double> &CalcOutput();
00027
00028 gplib::rvec WeightsAsVector;
00029
00030 double alpha;
00031
00032 double mu;
00033
00034 tNeuralArray Layers;
00035
00036 std::vector<double> LocInput;
00037
00038 std::vector<double> LocOutput;
00039
00040 std::vector<double> LocDesired;
00041
00042 void AdaptWeights();
00043 public:
00044
00045 void SetAlpha(const double a)
00046 {
00047 alpha = a;
00048 }
00049
00050 void SetMu(const double m)
00051 {
00052 mu = m;
00053 }
00054
00055 void SetLayers(ttypeArray typeArray, bool cachedoutput = false);
00056
00057 void InitWeights(const double MaxWeight, const double MaxBias);
00058
00059 void PrintTopology(std::string filename);
00060
00061 virtual void PrintWeights(std::ostream &output);
00062
00063 virtual const gplib::rvec &GetWeightsAsVector();
00064
00065 virtual void AdaptFilter(const gplib::rvec &Input,
00066 const gplib::rvec &Desired);
00067
00068 virtual void CalcOutput(const gplib::rvec &Input, gplib::rvec &Output);
00069
00070 NeuralNetwork(const int inputsize, const int outputsize);
00071
00072 NeuralNetwork(const int inputsize, const int outputsize,
00073 const double mu_, const ttypeArray &Layerssetup,
00074 const double maxinit, bool cachedoutput = false);
00075 virtual ~NeuralNetwork();
00076 };
00077
00078 }
00079 #endif // CNEURALNETWORK_H