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

itkTwoHiddenLayerBackPropagationNeuralNetwork.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkTwoHiddenLayerBackPropagationNeuralNetwork.h,v $
00005 Language:  C++
00006 Date:      $Date: 2009-01-28 21:04:59 $
00007 Version:   $Revision: 1.7 $
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 __itkTwoHiddenLayerBackPropagationNeuralNetwork_h
00018 #define __itkTwoHiddenLayerBackPropagationNeuralNetwork_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 #include "itkProductInputFunction.h"
00031 
00032 namespace itk
00033 {
00034 namespace Statistics
00035 {
00036 
00037 template<class TMeasurementVector, class TTargetVector>
00038 class TwoHiddenLayerBackPropagationNeuralNetwork :
00039     public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
00040 {
00041 public:
00042   typedef TwoHiddenLayerBackPropagationNeuralNetwork Self;
00043   typedef MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
00044                                                      Superclass;
00045   typedef SmartPointer<Self>                         Pointer;
00046   typedef SmartPointer<const Self>                   ConstPointer;
00047 
00048   typedef typename Superclass::ValueType             ValueType;
00049   typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
00050   typedef typename Superclass::TargetVectorType      TargetVectorType;
00051   typedef typename Superclass::NetworkOutputType     NetworkOutputType;
00052 
00053   typedef typename Superclass::LayerInterfaceType LayerInterfaceType;
00054   typedef typename Superclass::LearningLayerType  LearningLayerType;
00055 
00056   typedef typename Superclass::WeightVectorType WeightVectorType;
00057   typedef typename Superclass::LayerVectorType  LayerVectorType;
00058 
00059   typedef typename Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType;
00060   typedef typename Superclass::InputFunctionInterfaceType    InputFunctionInterfaceType;
00061 
00062   /* Method for creation through the object factory. */
00063   itkTypeMacro(TwoHiddenLayerBackPropagationNeuralNetwork,
00064                MultilayerNeuralNetworkBase);
00065   itkNewMacro(Self);
00066 
00067   //Add the layers to the network.
00068   // 1 input, 2 hidden, 1 output
00069   void Initialize();
00070   
00071   itkSetMacro(NumOfInputNodes, unsigned int);
00072   itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
00073 
00074   itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
00075   itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
00076 
00077   itkSetMacro(NumOfSecondHiddenNodes, unsigned int);
00078   itkGetConstReferenceMacro(NumOfSecondHiddenNodes,unsigned int);
00079   //#define __USE_OLD_INTERFACE  Comment out to ensure that new interface works
00080 #ifdef __USE_OLD_INTERFACE
00081   //Original Function name before consistency naming changes
00082   inline void SetNumOfHiddenNodes1(unsigned int x) { SetNumOfFirstHiddenNodes(x); }
00083   inline unsigned int GetNumOfHiddenNodes1(void) const { return GetNumOfFirstHiddenNodes(); }
00084   inline void SetNumOfHiddenNodes2(unsigned int x) { SetNumOfSecondHiddenNodes(x); }
00085   inline unsigned int GetNumOfHiddenNodes2(void) const { return GetNumOfSecondHiddenNodes(); }
00086 #endif
00087 
00088   itkSetMacro(NumOfOutputNodes, unsigned int);
00089   itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
00090   
00091   itkSetMacro(FirstHiddenLayerBias, ValueType);
00092   itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
00093   
00094   itkSetMacro(SecondHiddenLayerBias, ValueType);
00095   itkGetConstReferenceMacro(SecondHiddenLayerBias, ValueType);
00096 
00097   itkSetMacro(OutputLayerBias, ValueType);
00098   itkGetConstReferenceMacro(OutputLayerBias, ValueType);
00099 
00100   virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
00101   
00102   void SetInputFunction(InputFunctionInterfaceType* f);
00103   void SetInputTransferFunction(TransferFunctionInterfaceType* f);
00104   void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType* f);
00105   void SetSecondHiddenTransferFunction(TransferFunctionInterfaceType* f);
00106   void SetOutputTransferFunction(TransferFunctionInterfaceType* f);
00107 protected:
00108 
00109   TwoHiddenLayerBackPropagationNeuralNetwork();
00110   virtual ~TwoHiddenLayerBackPropagationNeuralNetwork() {};
00111   
00113   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00114 
00115 private:
00116   
00117   unsigned int m_NumOfInputNodes;
00118   unsigned int m_NumOfFirstHiddenNodes;
00119   unsigned int m_NumOfSecondHiddenNodes;
00120   unsigned int m_NumOfOutputNodes;
00121 
00122   ValueType m_FirstHiddenLayerBias;
00123   ValueType m_SecondHiddenLayerBias;
00124   ValueType m_OutputLayerBias;
00125 
00126   typename InputFunctionInterfaceType::Pointer    m_InputFunction;
00127   typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
00128   typename TransferFunctionInterfaceType::Pointer m_FirstHiddenTransferFunction;
00129   typename TransferFunctionInterfaceType::Pointer m_SecondHiddenTransferFunction;
00130   typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
00131 };
00132 
00133 } // end namespace Statistics
00134 } // end namespace itk
00135 
00136 #ifndef ITK_MANUAL_INSTANTIATION
00137 #include "itkTwoHiddenLayerBackPropagationNeuralNetwork.txx"
00138 #endif
00139 
00140 #endif
00141 

Generated at Mon Jul 12 2010 20:04:31 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000