ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkOneHiddenLayerBackPropagationNeuralNetwork.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkOneHiddenLayerBackPropagationNeuralNetwork_h
19 #define __itkOneHiddenLayerBackPropagationNeuralNetwork_h
20 
30 #include "itkSumInputFunction.h"
31 
32 
33 namespace itk
34 {
35 namespace Statistics
36 {
43 template<class TMeasurementVector, class TTargetVector>
45  public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
46 {
47 public:
53 
54  typedef typename Superclass::ValueType ValueType;
58 
61 
64 
69 
73  itkNewMacro(Self);
75 
76  //Add the layers to the network.
77  // 1 input, 1 hidden, 1 output
78  void Initialize();
79 
80  itkSetMacro(NumOfInputNodes, unsigned int);
81  itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
82 
83  itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
84  itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
85 
86  itkSetMacro(NumOfOutputNodes, unsigned int);
87  itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
88 
89  itkSetMacro(FirstHiddenLayerBias, ValueType);
90  itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
91 
92 //#define __USE_OLD_INTERFACE Comment out to ensure that new interface works
93 #ifdef __USE_OLD_INTERFACE
94  //Original Function name before consistency naming changes
95  inline void SetNumOfHiddenNodes(const unsigned int & x) { SetNumOfFirstHiddenNodes(x); }
96  inline unsigned int GetNumOfHiddenNodes(void) const { return GetNumOfFirstHiddenNodes(); }
97  inline void SetHiddenLayerBias(const ValueType & bias) { SetFirstHiddenLayerBias(bias); }
98  ValueType GetHiddenLayerBias(void) const { return GetFirstHiddenLayerBias();}
99 #endif
100  itkSetMacro(OutputLayerBias, ValueType);
101  itkGetConstReferenceMacro(OutputLayerBias, ValueType);
102 
103  virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
104 
107 #ifdef __USE_OLD_INTERFACE
108  //Original Function name before consistency naming changes
109  inline void SetHiddenTransferFunction(TransferFunctionInterfaceType* f) { SetFirstHiddenTransferFunction (f); }
110 #endif
113 
114 protected:
115 
118 
120  virtual void PrintSelf( std::ostream& os, Indent indent ) const;
121 
122 private:
123 
124  unsigned int m_NumOfInputNodes;
126  unsigned int m_NumOfOutputNodes;
127 
130 
131  typename InputFunctionInterfaceType::Pointer m_InputFunction;
132  typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
133  typename TransferFunctionInterfaceType::Pointer m_FirstHiddenTransferFunction;
134  typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
135 };
136 
137 } // end namespace Statistics
138 } // end namespace itk
139 
140 #ifndef ITK_MANUAL_INSTANTIATION
141 #include "itkOneHiddenLayerBackPropagationNeuralNetwork.hxx"
142 #endif
143 
144 #endif
145