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: 2007/08/17 13:10:57 $
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 __itkOneHiddenLayerBackPropNeuralNetworkBase_h
00018 #define __itkOneHiddenLayerBackPropNeuralNetworkBase_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> > 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(OneHiddenLayerBackPropagationNeuralNetwork,
00064           MultilayerNeuralNetworkBase);
00065         itkNewMacro(Self) ;
00066 
00067         //Add the layers to the network.
00068         // 1 input, 1 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(NumOfOutputNodes, unsigned int);
00078         itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
00079 
00080         itkSetMacro(FirstHiddenLayerBias, ValueType);
00081         itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
00082 
00083 //#define __USE_OLD_INTERFACE  Comment out to ensure that new interface works
00084 #ifdef __USE_OLD_INTERFACE
00085         //Original Function name before consistency naming changes
00086         inline void SetNumOfHiddenNodes(const unsigned int & x) { SetNumOfFirstHiddenNodes(x); }
00087         inline unsigned int GetNumOfHiddenNodes(void) const { return GetNumOfFirstHiddenNodes(); }
00088         inline void SetHiddenLayerBias(const ValueType & bias) { SetFirstHiddenLayerBias(bias); }
00089         ValueType GetHiddenLayerBias(void) const { return GetFirstHiddenLayerBias();};
00090 #endif
00091         itkSetMacro(OutputLayerBias, ValueType);
00092         itkGetConstReferenceMacro(OutputLayerBias, ValueType);
00093 
00094         virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
00095 
00096         void SetInputFunction(InputFunctionInterfaceType* f);
00097         void SetInputTransferFunction(TransferFunctionInterfaceType* f);
00098 #ifdef __USE_OLD_INTERFACE
00099         //Original Function name before consistency naming changes
00100         inline void SetHiddenTransferFunction(TransferFunctionInterfaceType* f) { SetFirstHiddenTransferFunction (f); };
00101 #endif
00102         void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType* f);
00103         void SetOutputTransferFunction(TransferFunctionInterfaceType* f);
00104       protected:
00105 
00106         OneHiddenLayerBackPropagationNeuralNetwork();
00107         virtual ~OneHiddenLayerBackPropagationNeuralNetwork(){};
00108 
00110         virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00111 
00112       private:
00113 
00114         unsigned int m_NumOfInputNodes;
00115         unsigned int m_NumOfFirstHiddenNodes;
00116         unsigned int m_NumOfOutputNodes;
00117 
00118         ValueType m_FirstHiddenLayerBias;
00119         ValueType m_OutputLayerBias;
00120 
00121         typename InputFunctionInterfaceType::Pointer    m_InputFunction;
00122         typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
00123         typename TransferFunctionInterfaceType::Pointer m_FirstHiddenTransferFunction;
00124         typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
00125         };
00126 
00127     } // end namespace Statistics
00128 } // end namespace itk
00129 
00130 #ifndef ITK_MANUAL_INSTANTIATION
00131 #include "itkOneHiddenLayerBackPropagationNeuralNetwork.txx"
00132 #endif
00133 
00134 #endif
00135 

Generated at Tue Jul 29 21:35:19 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000