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-01-28 21:04:59 $
00007 Version:   $Revision: 1.9 $
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 #include "itkEuclideanDistance.h"
00034 #include "itkRBFLayer.h"
00035 
00036 namespace itk
00037 {
00038 namespace Statistics
00039 {
00040 
00041 template<class TMeasurementVector, class TTargetVector>
00042 class RBFNetwork :
00043     public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
00044 {
00045 public:
00046   typedef RBFNetwork               Self;
00047   typedef MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector , BackPropagationLayer<TMeasurementVector, TTargetVector> >
00048                                    Superclass;
00049   typedef SmartPointer<Self>       Pointer;
00050   typedef SmartPointer<const Self> ConstPointer;
00051 
00052   typedef typename Superclass::ValueType             ValueType;
00053   typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
00054   typedef typename Superclass::TargetVectorType      TargetVectorType;
00055   typedef typename Superclass::NetworkOutputType     NetworkOutputType;
00056 
00057   typedef typename Superclass::LayerInterfaceType LayerInterfaceType;
00058   typedef typename Superclass::LearningLayerType  LearningLayerType;
00059 
00060   typedef typename Superclass::WeightVectorType WeightVectorType;
00061   typedef typename Superclass::LayerVectorType  LayerVectorType;
00062 
00063   typedef typename Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType;
00064   typedef typename Superclass::InputFunctionInterfaceType    InputFunctionInterfaceType;
00065   
00066   // Specializations for RBF Networks
00067   typedef Array<ValueType>                            ArrayType;
00068   typedef EuclideanDistance<ArrayType>                DistanceMetricType;
00069   typedef RadialBasisFunctionBase<ValueType>          RBFTransferFunctionType;
00070   typedef RBFLayer<TMeasurementVector, TTargetVector> HiddenLayerType;
00071 
00072   itkSetMacro(Classes, unsigned int);
00073   itkGetConstReferenceMacro(Classes, unsigned int);
00074   void SetCenter(TMeasurementVector c);
00075   void SetRadius(ValueType r);
00076   void SetDistanceMetric(DistanceMetricType* f);
00077   void InitializeWeights();
00078 
00079   /* Method for creation through the object factory. */
00080   itkTypeMacro(RBFNetwork,
00081                MultilayerNeuralNetworkBase);
00082   itkNewMacro(Self);
00083 
00084   //Add the layers to the network.
00085   // 1 input, 1 hidden, 1 output
00086   void Initialize();
00087 
00088   itkSetMacro(NumOfInputNodes, unsigned int);
00089   itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
00090 
00091   itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
00092   itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
00093 
00094   itkSetMacro(NumOfOutputNodes, unsigned int);
00095   itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
00096 
00097   itkSetMacro(FirstHiddenLayerBias, ValueType);
00098   itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
00099 
00100   //#define __USE_OLD_INTERFACE  Comment out to ensure that new interface works
00101 #ifdef __USE_OLD_INTERFACE
00102   //Original Function name before consistency naming changes
00103   inline void SetNumOfHiddenNodes(const unsigned int & x) { SetNumOfFirstHiddenNodes(x); }
00104   inline unsigned int GetNumOfHiddenNodes(void) const { return GetNumOfFirstHiddenNodes(); }
00105   inline void SetHiddenLayerBias(const ValueType & bias) { SetFirstHiddenLayerBias(bias); }
00106   ValueType GetHiddenLayerBias(void) const { return GetFirstHiddenLayerBias();}
00107 #endif
00108   itkSetMacro(OutputLayerBias, ValueType);
00109   itkGetConstReferenceMacro(OutputLayerBias, ValueType);
00110 
00111   virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
00112 
00113   void SetInputFunction(InputFunctionInterfaceType* f);
00114   void SetInputTransferFunction(TransferFunctionInterfaceType* f);
00115 #ifdef __USE_OLD_INTERFACE
00116   //Original Function name before consistency naming changes
00117   inline void SetHiddenTransferFunction(TransferFunctionInterfaceType* f) { SetFirstHiddenTransferFunction (f); }
00118 #endif
00119   void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType* f);
00120   void SetOutputTransferFunction(TransferFunctionInterfaceType* f);
00121 protected:
00122 
00123   RBFNetwork();
00124   virtual ~RBFNetwork(){};
00125 
00127   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00128 
00129 private:
00130 
00131   typename DistanceMetricType::Pointer            m_DistanceMetric;
00132   std::vector<TMeasurementVector>                 m_Centers;  // ui....uc
00133   std::vector<double>                             m_Radii;
00134 
00135   unsigned int m_Classes;
00136   unsigned int m_NumOfInputNodes;
00137   unsigned int m_NumOfFirstHiddenNodes;
00138   unsigned int m_NumOfOutputNodes;
00139 
00140   ValueType m_FirstHiddenLayerBias;
00141   ValueType m_OutputLayerBias;
00142   
00143   typename InputFunctionInterfaceType::Pointer    m_InputFunction;
00144   typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
00145   typename RBFTransferFunctionType::Pointer       m_FirstHiddenTransferFunction;
00146   typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
00147 };
00148 
00149 } // end namespace Statistics
00150 } // end namespace itk
00151 
00152 #ifndef ITK_MANUAL_INSTANTIATION
00153 #include "itkRBFNetwork.txx"
00154 #endif
00155 
00156 #endif
00157 

Generated at Sat Feb 28 13:24:01 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000