00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
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
00063 itkTypeMacro(OneHiddenLayerBackPropagationNeuralNetwork,
00064 MultilayerNeuralNetworkBase);
00065 itkNewMacro(Self) ;
00066
00067
00068
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
00084 #ifdef __USE_OLD_INTERFACE
00085
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
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 }
00128 }
00129
00130 #ifndef ITK_MANUAL_INSTANTIATION
00131 #include "itkOneHiddenLayerBackPropagationNeuralNetwork.txx"
00132 #endif
00133
00134 #endif
00135