Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkRBFNetwork.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkRBFNetwork.h,v $
00005 Language:  C++
00006 Date:      $Date: 2009-05-02 05:43:55 $
00007 Version:   $Revision: 1.10 $
00008 
00009 Copyright (c) Insight Software Consortium. All rights reserved.
00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012 This software is distributed WITHOUT ANY WARRANTY; without even
00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014 PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkRBFNetwork_h
00018 #define __itkRBFNetwork_h
00019 
00020 #include "itkMultilayerNeuralNetworkBase.h"
00021 #include "itkBackPropagationLayer.h"
00022 #include "itkSigmoidTransferFunction.h"
00023 #include "itkLogSigmoidTransferFunction.h"
00024 #include "itkTanSigmoidTransferFunction.h"
00025 #include "itkHardLimitTransferFunction.h"
00026 #include "itkSignedHardLimitTransferFunction.h"
00027 #include "itkGaussianTransferFunction.h"
00028 #include "itkIdentityTransferFunction.h"
00029 #include "itkSumInputFunction.h"
00030 
00031 #include "itkSymmetricSigmoidTransferFunction.h"
00032 #include "itkTanHTransferFunction.h"
00033 #ifdef ITK_USE_REVIEW_STATISTICS
00034 #include "itkEuclideanDistanceMetric.h"
00035 #else
00036 #include "itkEuclideanDistance.h"
00037 #endif
00038 #include "itkRBFLayer.h"
00039 
00040 namespace itk
00041 {
00042 namespace Statistics
00043 {
00044 
00045 template<class TMeasurementVector, class TTargetVector>
00046 class RBFNetwork :
00047     public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
00048 {
00049 public:
00050   typedef RBFNetwork               Self;
00051   typedef MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector , BackPropagationLayer<TMeasurementVector, TTargetVector> >
00052                                    Superclass;
00053   typedef SmartPointer<Self>       Pointer;
00054   typedef SmartPointer<const Self> ConstPointer;
00055 
00056   typedef typename Superclass::ValueType             ValueType;
00057   typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
00058   typedef typename Superclass::TargetVectorType      TargetVectorType;
00059   typedef typename Superclass::NetworkOutputType     NetworkOutputType;
00060 
00061   typedef typename Superclass::LayerInterfaceType LayerInterfaceType;
00062   typedef typename Superclass::LearningLayerType  LearningLayerType;
00063 
00064   typedef typename Superclass::WeightVectorType WeightVectorType;
00065   typedef typename Superclass::LayerVectorType  LayerVectorType;
00066 
00067   typedef typename Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType;
00068   typedef typename Superclass::InputFunctionInterfaceType    InputFunctionInterfaceType;
00069   
00070   // Specializations for RBF Networks
00071   typedef Array<ValueType>                            ArrayType;
00072 #ifdef ITK_USE_REVIEW_STATISTICS
00073   typedef EuclideanDistanceMetric<ArrayType>                DistanceMetricType;
00074 #else
00075   typedef EuclideanDistance<ArrayType>                DistanceMetricType;
00076 #endif
00077   typedef RadialBasisFunctionBase<ValueType>          RBFTransferFunctionType;
00078   typedef RBFLayer<TMeasurementVector, TTargetVector> HiddenLayerType;
00079 
00080   itkSetMacro(Classes, unsigned int);
00081   itkGetConstReferenceMacro(Classes, unsigned int);
00082   void SetCenter(TMeasurementVector c);
00083   void SetRadius(ValueType r);
00084   void SetDistanceMetric(DistanceMetricType* f);
00085   void InitializeWeights();
00086 
00087   /* Method for creation through the object factory. */
00088   itkTypeMacro(RBFNetwork,
00089                MultilayerNeuralNetworkBase);
00090   itkNewMacro(Self);
00091 
00092   //Add the layers to the network.
00093   // 1 input, 1 hidden, 1 output
00094   void Initialize();
00095 
00096   itkSetMacro(NumOfInputNodes, unsigned int);
00097   itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
00098 
00099   itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
00100   itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
00101 
00102   itkSetMacro(NumOfOutputNodes, unsigned int);
00103   itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
00104 
00105   itkSetMacro(FirstHiddenLayerBias, ValueType);
00106   itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
00107 
00108   //#define __USE_OLD_INTERFACE  Comment out to ensure that new interface works
00109 #ifdef __USE_OLD_INTERFACE
00110   //Original Function name before consistency naming changes
00111   inline void SetNumOfHiddenNodes(const unsigned int & x) { SetNumOfFirstHiddenNodes(x); }
00112   inline unsigned int GetNumOfHiddenNodes(void) const { return GetNumOfFirstHiddenNodes(); }
00113   inline void SetHiddenLayerBias(const ValueType & bias) { SetFirstHiddenLayerBias(bias); }
00114   ValueType GetHiddenLayerBias(void) const { return GetFirstHiddenLayerBias();}
00115 #endif
00116   itkSetMacro(OutputLayerBias, ValueType);
00117   itkGetConstReferenceMacro(OutputLayerBias, ValueType);
00118 
00119   virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
00120 
00121   void SetInputFunction(InputFunctionInterfaceType* f);
00122   void SetInputTransferFunction(TransferFunctionInterfaceType* f);
00123 #ifdef __USE_OLD_INTERFACE
00124   //Original Function name before consistency naming changes
00125   inline void SetHiddenTransferFunction(TransferFunctionInterfaceType* f) { SetFirstHiddenTransferFunction (f); }
00126 #endif
00127   void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType* f);
00128   void SetOutputTransferFunction(TransferFunctionInterfaceType* f);
00129 protected:
00130 
00131   RBFNetwork();
00132   virtual ~RBFNetwork(){};
00133 
00135   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00136 
00137 private:
00138 
00139   typename DistanceMetricType::Pointer            m_DistanceMetric;
00140   std::vector<TMeasurementVector>                 m_Centers;  // ui....uc
00141   std::vector<double>                             m_Radii;
00142 
00143   unsigned int m_Classes;
00144   unsigned int m_NumOfInputNodes;
00145   unsigned int m_NumOfFirstHiddenNodes;
00146   unsigned int m_NumOfOutputNodes;
00147 
00148   ValueType m_FirstHiddenLayerBias;
00149   ValueType m_OutputLayerBias;
00150   
00151   typename InputFunctionInterfaceType::Pointer    m_InputFunction;
00152   typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
00153   typename RBFTransferFunctionType::Pointer       m_FirstHiddenTransferFunction;
00154   typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
00155 };
00156 
00157 } // end namespace Statistics
00158 } // end namespace itk
00159 
00160 #ifndef ITK_MANUAL_INSTANTIATION
00161 #include "itkRBFNetwork.txx"
00162 #endif
00163 
00164 #endif
00165 

Generated at Thu May 28 11:19:33 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000