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

itkOneHiddenLayerBackPropagationNeuralNetwork.h

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

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