00001 #ifndef RBFWEIGHTLAYER_H 00002 #define RBFWEIGHTLAYER_H 00003 00004 #include "IWeightLayerToHidden.hpp" 00005 #include "IWeightLayerToOutput.hpp" 00006 #include <map> 00007 00008 00013 class RBFWeightLayer : public IWeightLayerToHidden, public IWeightLayerToOutput 00014 { 00015 public: 00016 RBFWeightLayer(unsigned int nofOutputNodes) { m_nofOutputNodes = nofOutputNodes; } 00017 ~RBFWeightLayer() 00018 { 00019 std::map<RBFNode *, RBFWeights *>::iterator it = m_weights.begin(); 00020 00021 // free some memory 00022 for(; it != m_weights.end(); it++) 00023 delete (*it).second; 00024 00025 } 00026 00027 virtual void CreateWeightsObject(RBFNode * n) 00028 { 00029 RBFWeights * w = new RBFWeights(m_nofOutputNodes); 00030 m_weights[n] = w; 00031 } 00032 00033 virtual void DeleteWeightsObject(RBFNode * n) 00034 { 00035 delete m_weights[n]; 00036 m_weights.erase(n); 00037 } 00038 00039 virtual void SetSignal(RBFNode * n, double s) 00040 { 00041 m_weights[n]->SetSignal(s); 00042 } 00043 00044 virtual double GetWeightedSum(unsigned int outputNodeIndex) 00045 { 00046 double weightedSum = 0.0; 00047 00048 std::map<RBFNode *, RBFWeights *>::iterator it = m_weights.begin(); 00049 for(; it != m_weights.end(); it++) 00050 { 00051 RBFWeights & w = *((*it).second); 00052 weightedSum += w.GetWeightedSignal(outputNodeIndex); 00053 } 00054 00055 return weightedSum; 00056 } 00057 00058 virtual void UpdateWeights(Vector & etaDiff) 00059 { 00060 std::map<RBFNode *, RBFWeights *>::iterator it = m_weights.begin(); 00061 for(; it != m_weights.end(); it++) 00062 (*it).second->UpdateWeights(etaDiff); 00063 } 00064 00065 private: 00066 std::map<RBFNode *, RBFWeights *> m_weights; 00067 unsigned int m_nofOutputNodes; 00068 00069 00070 }; 00071 00072 #endif 00073 00074 00075 00076 00077 00078 00079 00080