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: 2007/08/17 13:10:57 $
00007 Version:   $Revision: 1.6 $
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 __itkTwoHiddenLayerBackPropNeuralNetworkBase_h
00018 #define __itkTwoHiddenLayerBackPropNeuralNetworkBase_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> > Superclass;
00044         typedef SmartPointer<Self> Pointer;
00045         typedef SmartPointer<const Self> ConstPointer;
00046 
00047         typedef typename Superclass::ValueType ValueType;
00048         typedef typename Superclass::MeasurementVectorType MeasurementVectorType;
00049         typedef typename Superclass::TargetVectorType TargetVectorType;
00050         typedef typename Superclass::NetworkOutputType NetworkOutputType;
00051 
00052         typedef typename Superclass::LayerInterfaceType LayerInterfaceType;
00053         typedef typename Superclass::LearningLayerType LearningLayerType;
00054 
00055         typedef typename Superclass::WeightVectorType WeightVectorType;
00056         typedef typename Superclass::LayerVectorType LayerVectorType;
00057 
00058         typedef typename Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType;
00059         typedef typename Superclass::InputFunctionInterfaceType InputFunctionInterfaceType;
00060 
00061         /* Method for creation through the object factory. */
00062         itkTypeMacro(TwoHiddenLayerBackPropagationNeuralNetwork,
00063           MultilayerNeuralNetworkBase);
00064         itkNewMacro(Self) ;
00065 
00066         //Add the layers to the network.
00067         // 1 input, 2 hidden, 1 output
00068         void Initialize();
00069 
00070         itkSetMacro(NumOfInputNodes, unsigned int);
00071         itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
00072 
00073         itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
00074         itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
00075 
00076         itkSetMacro(NumOfSecondHiddenNodes, unsigned int);
00077         itkGetConstReferenceMacro(NumOfSecondHiddenNodes,unsigned int);
00078 //#define __USE_OLD_INTERFACE  Comment out to ensure that new interface works
00079 #ifdef __USE_OLD_INTERFACE
00080         //Original Function name before consistency naming changes
00081         inline void SetNumOfHiddenNodes1(unsigned int x) { SetNumOfFirstHiddenNodes(x); }
00082         inline unsigned int GetNumOfHiddenNodes1(void) const { return GetNumOfFirstHiddenNodes(); }
00083         inline void SetNumOfHiddenNodes2(unsigned int x) { SetNumOfSecondHiddenNodes(x); }
00084         inline unsigned int GetNumOfHiddenNodes2(void) const { return GetNumOfSecondHiddenNodes(); }
00085 #endif
00086 
00087         itkSetMacro(NumOfOutputNodes, unsigned int);
00088         itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
00089 
00090         itkSetMacro(FirstHiddenLayerBias, ValueType);
00091         itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
00092 
00093         itkSetMacro(SecondHiddenLayerBias, ValueType);
00094         itkGetConstReferenceMacro(SecondHiddenLayerBias, ValueType);
00095 
00096         itkSetMacro(OutputLayerBias, ValueType);
00097         itkGetConstReferenceMacro(OutputLayerBias, ValueType);
00098 
00099         virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
00100 
00101         void SetInputFunction(InputFunctionInterfaceType* f);
00102         void SetInputTransferFunction(TransferFunctionInterfaceType* f);
00103         void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType* f);
00104         void SetSecondHiddenTransferFunction(TransferFunctionInterfaceType* f);
00105         void SetOutputTransferFunction(TransferFunctionInterfaceType* f);
00106       protected:
00107 
00108         TwoHiddenLayerBackPropagationNeuralNetwork();
00109         virtual ~TwoHiddenLayerBackPropagationNeuralNetwork() {};
00110 
00112         virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00113 
00114       private:
00115 
00116         unsigned int m_NumOfInputNodes;
00117         unsigned int m_NumOfFirstHiddenNodes;
00118         unsigned int m_NumOfSecondHiddenNodes;
00119         unsigned int m_NumOfOutputNodes;
00120 
00121         ValueType m_FirstHiddenLayerBias;
00122         ValueType m_SecondHiddenLayerBias;
00123         ValueType m_OutputLayerBias;
00124 
00125         typename InputFunctionInterfaceType::Pointer    m_InputFunction;
00126         typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
00127         typename TransferFunctionInterfaceType::Pointer m_FirstHiddenTransferFunction;
00128         typename TransferFunctionInterfaceType::Pointer m_SecondHiddenTransferFunction;
00129         typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
00130         };
00131 
00132     } // end namespace Statistics
00133 } // end namespace itk
00134 
00135 #ifndef ITK_MANUAL_INSTANTIATION
00136 #include "itkTwoHiddenLayerBackPropagationNeuralNetwork.txx"
00137 #endif
00138 
00139 #endif
00140 
00141 

Generated at Tue Jul 29 23:04:53 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000