Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SOM.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLMath/src/ICLMath/SOM.h                              **
00010 ** Module : ICLMath                                                **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.GPL  **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLUtils/Range.h>
00034 #include <ICLUtils/SmartPtr.h>
00035 #include <vector>
00036 
00037 namespace icl{
00038   namespace math{
00039   
00041 
00069     class SOM{
00070       public:
00072 
00075       struct Neuron{
00076         typedef utils::SmartPtr<float> vector_type;
00077         
00079         Neuron(){}
00081 
00085         Neuron(vector_type gridpos,vector_type prototype,unsigned int griddim, unsigned int datadim);
00086   
00088         vector_type gridpos;
00089         
00091         vector_type prototype;
00092   
00094         unsigned int griddim;
00095         
00097         unsigned int datadim;
00098         
00100         void *meta;
00101         
00103         inline bool isNull() const { return !!gridpos; }
00104       };
00105       
00107 
00118       SOM(unsigned int dataDim, const std::vector<unsigned int> &dims,
00119           const std::vector<utils::Range<float> > &prototypeBounds, 
00120           float epsilon=0.1, float sigma=1);
00121   
00123       ~SOM();
00124       
00126       void train(const float *input);
00127       
00129       const Neuron &getWinner(const float *input) const;
00130   
00132       Neuron &getWinner(const float *input);
00133       
00135       const std::vector<Neuron> &getNeurons() const; 
00136       
00138       std::vector<Neuron> &getNeurons();
00139       
00141       const Neuron &getNeuron(const std::vector<int> &dims) const;
00142   
00144       Neuron &getNeuron(const std::vector<int> &dims);
00145       
00147       unsigned int getDataDim() const { return m_uiDataDim; }
00148   
00150       unsigned int getSomDim() const { return m_uiSomDim; }
00151       
00153       const std::vector<unsigned int> getDimensions() const { return m_vecDimensions; }
00154   
00156       void setEpsilon(float epsilon);
00157       
00159       void setSigma(float sigma);
00160       
00161       protected:
00162       
00164       unsigned int m_uiDataDim;
00165       
00167       unsigned int m_uiSomDim;
00168       
00170       std::vector<unsigned int> m_vecDimensions;
00171       
00173       std::vector<utils::Range<float> > m_vecPrototypeBounds;
00174       
00176       std::vector<Neuron> m_vecNeurons;
00177       
00179       std::vector<unsigned int> m_vecDimOffsets;
00180       
00182       float m_fEpsilon; 
00183   
00185       float m_fSigma;   
00186     };
00187     
00188   
00189   } // namespace math
00190 }
00191 
00192 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines