ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkTwoHiddenLayerBackPropagationNeuralNetwork.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 itkTwoHiddenLayerBackPropagationNeuralNetwork_h
19 #define itkTwoHiddenLayerBackPropagationNeuralNetwork_h
20 
30 #include "itkSumInputFunction.h"
32 
33 namespace itk
34 {
35 namespace Statistics
36 {
43 template<typename TMeasurementVector, typename TTargetVector>
45  public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
46 {
47 public:
53 
54  typedef typename Superclass::ValueType ValueType;
58 
61 
64 
67 
71  itkNewMacro(Self);
73 
74  //Add the layers to the network.
75  // 1 input, 2 hidden, 1 output
76  void Initialize() ITK_OVERRIDE;
77 
78  itkSetMacro(NumOfInputNodes, unsigned int);
79  itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
80 
81  itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
82  itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
83 
84  itkSetMacro(NumOfSecondHiddenNodes, unsigned int);
85  itkGetConstReferenceMacro(NumOfSecondHiddenNodes,unsigned int);
86  //#define __USE_OLD_INTERFACE Comment out to ensure that new interface works
87 #ifdef __USE_OLD_INTERFACE
88  //Original Function name before consistency naming changes
89  inline void SetNumOfHiddenNodes1(unsigned int x) { SetNumOfFirstHiddenNodes(x); }
90  inline unsigned int GetNumOfHiddenNodes1(void) const { return GetNumOfFirstHiddenNodes(); }
91  inline void SetNumOfHiddenNodes2(unsigned int x) { SetNumOfSecondHiddenNodes(x); }
92  inline unsigned int GetNumOfHiddenNodes2(void) const { return GetNumOfSecondHiddenNodes(); }
93 #endif
94 
95  itkSetMacro(NumOfOutputNodes, unsigned int);
96  itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
97 
98  itkSetMacro(FirstHiddenLayerBias, ValueType);
99  itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
100 
101  itkSetMacro(SecondHiddenLayerBias, ValueType);
102  itkGetConstReferenceMacro(SecondHiddenLayerBias, ValueType);
103 
104  itkSetMacro(OutputLayerBias, ValueType);
105  itkGetConstReferenceMacro(OutputLayerBias, ValueType);
106 
107  virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector) ITK_OVERRIDE;
108 
114 
115 protected:
116 
119 
121  virtual void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
122 
123 private:
124 
125  unsigned int m_NumOfInputNodes;
128  unsigned int m_NumOfOutputNodes;
129 
133 
134  typename InputFunctionInterfaceType::Pointer m_InputFunction;
135  typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
136  typename TransferFunctionInterfaceType::Pointer m_FirstHiddenTransferFunction;
137  typename TransferFunctionInterfaceType::Pointer m_SecondHiddenTransferFunction;
138  typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
139 };
140 
141 } // end namespace Statistics
142 } // end namespace itk
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "itkTwoHiddenLayerBackPropagationNeuralNetwork.hxx"
146 #endif
147 
148 #endif
This is the itkTwoHiddenLayerBackPropagationNeuralNetwork class.
virtual const unsigned int & GetNumOfFirstHiddenNodes() const
void SetSecondHiddenTransferFunction(TransferFunctionInterfaceType *f)
void SetInputFunction(InputFunctionInterfaceType *f)
virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector) override
MultilayerNeuralNetworkBase< TMeasurementVector, TTargetVector, BackPropagationLayer< TMeasurementVector, TTargetVector > > Superclass
virtual void PrintSelf(std::ostream &os, Indent indent) const override
MeasurementVectorType::ValueType ValueType
void SetInputTransferFunction(TransferFunctionInterfaceType *f)
This is the itkMultilayerNeuralNetworkBase class.
virtual const unsigned int & GetNumOfSecondHiddenNodes() const
void SetOutputTransferFunction(TransferFunctionInterfaceType *f)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType *f)
Base class for all data objects in ITK.