TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/STSOMFeaturePlane.h
Go to the documentation of this file.
00001 #ifndef STSOMFeaturePlane_H_INCLUDED
00002 #define STSOMFeaturePlane_H_INCLUDED
00003 
00004 #include  <qimage.h>
00005 
00006 #include "nowarn.h"
00007 #include "common.h"
00008 #include <stdlib.h>
00009 
00010 #include "OutputImage.h"
00011 #include "LearningFeaturePlane.h"
00012 #include "FilterBank.h"
00013 #include "PlaneInputWindowSet.h"
00014 #include "MatrixOfMatrix.h"
00015 
00016 //#define LISSOM
00017 
00018 
00020 class STSOMFeaturePlane : public LearningFeaturePlane {
00021         friend class GatingUnits;
00022         friend class FeaturePlaneFactory;
00023 public:
00024     ~STSOMFeaturePlane();
00025         void read(QDataStream* inStream, QProgressDialog* progress, int* index);
00026 
00027         void save(QDataStream* outStream, QProgressDialog* progress, int* index);
00028         bool isLearning();
00029         
00030     FeaturePlaneInput* addFilter(Filter* f, FeaturePlaneAbstract*fp, int type, int fpOutputIndex, bool wta);
00031         void incWinCount(){
00032                 winCount++;
00033         }
00034         int getWinCount(){
00035                 return winCount;
00036         }
00037 
00038 protected:
00039         
00056         STSOMFeaturePlane( Network* net, int l, QString* name, int w, int h, int angles, int speeds, int alpha, int speed, bool isWTA, bool visible, Neuron* neuron, NotifyStrategyAbstract* notify, bool learning);
00057         void step();
00058         
00059         float nonlinearity(Matrix* totalActivation, OutputImage* workOutput);
00060     void computeGatingUnits(); 
00061     
00062     //Total activation, to compute lateral contributions
00063     Matrix* getTotalActivation();
00064     //lateral interaction converged?
00065     bool hasConverged(){
00066         return isConverged;
00067     }
00068 
00069 private:
00070         static const char* FilterFileName;
00071         static const char* EFilterFileName;
00072         static const char* IFilterFileName;
00073     static const char* DumpFileName;
00074 
00076         vector<RandomFilter*> theInputFilters;
00077         vector<RandomFilter*> excitatoryFilters;
00078         vector<RandomFilter*> inhibitoryFilters;
00079         void saveFilters(int step);
00080 
00082     int winCount;
00084         int stepCount;
00085 
00086     bool isInputSameAsLast();
00087 
00088 #ifndef LISSOM
00089     QPoint lastWinner;
00090     Matrix* decision;
00091 #endif
00092 
00093 
00094     //synchronize execution within layer
00095         void sync();
00096     static int localProgressThreads;
00097     static QWaitCondition localProgressCond;
00098     static QMutex localProgressMutex;
00099 
00100     //lateral interaction converged?
00101     bool isConverged;
00102 
00103         void learn();
00104         void learn(uint32_t x, uint32_t y);
00105         void updateWeights(RandomFilter* theFilter, Matrix* input, float alpha, uint32_t x, uint32_t y);
00106         void updateWeightsLateral(RandomFilter* theFilter, Matrix* input, float alpha, uint32_t x, uint32_t y);
00107 
00108     void addLateralContribution(Filter* filter, Matrix* currentOtherFPActivation, Matrix* workActivation, float factor, bool sameFP);
00109     void applyLateralInhibition(Matrix* workActivation);
00110 
00111     float alpha();
00112         static float surround(int step);
00113 };
00114 #endif //STSOMFeaturePlane_H_INCLUDED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines