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.LGPL **
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/CompatMacros.h>
00034 #include <ICLUtils/Range.h>
00035 #include <ICLUtils/SmartPtr.h>
00036 #include <vector>
00037 
00038 namespace icl{
00039   namespace math{
00040   
00042 
00070     class ICLMath_API SOM{
00071       public:
00073 
00076       struct ICLMath_API Neuron{
00077         typedef utils::SmartPtr<float> vector_type;
00078         
00080         Neuron(){}
00082 
00086         Neuron(vector_type gridpos,vector_type prototype,unsigned int griddim, unsigned int datadim);
00087   
00089         vector_type gridpos;
00090         
00092         vector_type prototype;
00093   
00095         unsigned int griddim;
00096         
00098         unsigned int datadim;
00099         
00101         void *meta;
00102         
00104         inline bool isNull() const { return !!gridpos; }
00105       };
00106       
00108 
00119       SOM(unsigned int dataDim, const std::vector<unsigned int> &dims,
00120           const std::vector<utils::Range<float> > &prototypeBounds, 
00121           float epsilon=0.1, float sigma=1);
00122   
00124       ~SOM();
00125       
00127       void train(const float *input);
00128       
00130       const Neuron &getWinner(const float *input) const;
00131   
00133       Neuron &getWinner(const float *input);
00134       
00136       const std::vector<Neuron> &getNeurons() const; 
00137       
00139       std::vector<Neuron> &getNeurons();
00140       
00142       const Neuron &getNeuron(const std::vector<int> &dims) const;
00143   
00145       Neuron &getNeuron(const std::vector<int> &dims);
00146       
00148       unsigned int getDataDim() const { return m_uiDataDim; }
00149   
00151       unsigned int getSomDim() const { return m_uiSomDim; }
00152       
00154       const std::vector<unsigned int> getDimensions() const { return m_vecDimensions; }
00155   
00157       void setEpsilon(float epsilon);
00158       
00160       void setSigma(float sigma);
00161       
00162       protected:
00163       
00165       unsigned int m_uiDataDim;
00166       
00168       unsigned int m_uiSomDim;
00169       
00171       std::vector<unsigned int> m_vecDimensions;
00172       
00174       std::vector<utils::Range<float> > m_vecPrototypeBounds;
00175       
00177       std::vector<Neuron> m_vecNeurons;
00178       
00180       std::vector<unsigned int> m_vecDimOffsets;
00181       
00183       float m_fEpsilon; 
00184   
00186       float m_fSigma;   
00187     };
00188     
00189   
00190   } // namespace math
00191 }
00192 
00193 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines