RBFNetwork.hpp

Go to the documentation of this file.
00001 #ifndef __RBFNETWORK_H
00002 #define __RBFNETWORK_H
00003 
00004 #include <Vector.hpp>
00005 #include <iostream>
00006 #include "RBFHiddenLayer.hpp"
00007 #include "RBFOutputLayer.hpp"
00008 
00012 class RBFNetwork
00013 {
00014 public:
00021     RBFNetwork(/*unsigned int nofInputs, */RBFHiddenLayer * h, RBFWeightLayer * w, RBFOutputLayer * o)
00022     {
00023         m_hiddenLayer = h;
00024         m_weightLayer = w;
00025         m_outputLayer = o;
00026 
00027         //m_inputs = Vector(nofInputs);
00028         m_latestOutput = Vector(m_outputLayer->GetNofOutputs());
00029         m_eta = 0.2; //default
00030     }
00031 
00036     void SetParameterEta(double eta) { m_eta = eta; }
00037 
00043     virtual Vector Recall(Vector const & input)
00044     {
00045         m_hiddenLayer->ApplyInput(input);
00046         Vector const & v = m_outputLayer->GetOutput();
00047         m_latestOutput = v;
00048         return v;
00049     }
00050 
00055     virtual void Train(Vector const & output)
00056     {
00057         Vector etaDiff(output.size());
00058 
00059         Vector::iterator e = etaDiff.begin();
00060         Vector::iterator y = m_latestOutput.begin();
00061         Vector::const_iterator d = output.begin();
00062 
00063         for(; d < output.end(); d++, y++, e++)
00064             (*e) = m_eta * ( (*d)-(*y) );   // stepsize * (desired_output - actual_output)
00065 
00066         // 1. train weights
00067         m_weightLayer->UpdateWeights(etaDiff);
00068 
00069         // 2. train bias        
00070         m_outputLayer->UpdateBias(etaDiff);
00071     }
00072 
00073 private:
00074     //Vector  m_inputs;
00075     Vector  m_latestOutput;
00076     double  m_eta;
00077 
00078     RBFHiddenLayer * m_hiddenLayer;
00079     RBFWeightLayer * m_weightLayer;
00080     RBFOutputLayer * m_outputLayer;
00081 };
00082 
00083 
00084 #endif

Generated on Mon Mar 22 16:40:48 2004 for GNG_GL by doxygen 1.3.6