ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkRBFNetwork.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 __itkRBFNetwork_h
19 #define __itkRBFNetwork_h
20 
30 #include "itkSumInputFunction.h"
31 
34 #include "itkRBFLayer.h"
35 
36 namespace itk
37 {
38 namespace Statistics
39 {
46 template<class TMeasurementVector, class TTargetVector>
47 class RBFNetwork :
48  public MultilayerNeuralNetworkBase<TMeasurementVector, TTargetVector, BackPropagationLayer<TMeasurementVector, TTargetVector> >
49 {
50 public:
51  typedef RBFNetwork Self;
56 
57  typedef typename Superclass::ValueType ValueType;
61 
64 
67 
70 
71  // Specializations for RBF Networks
76 
77  itkSetMacro(Classes, unsigned int);
78  itkGetConstReferenceMacro(Classes, unsigned int);
79  void SetCenter(TMeasurementVector c);
80  void SetRadius(ValueType r);
82  void InitializeWeights();
83 
85  itkTypeMacro(RBFNetwork,
87  itkNewMacro(Self);
89 
90  //Add the layers to the network.
91  // 1 input, 1 hidden, 1 output
92  void Initialize();
93 
94  itkSetMacro(NumOfInputNodes, unsigned int);
95  itkGetConstReferenceMacro(NumOfInputNodes, unsigned int);
96 
97  itkSetMacro(NumOfFirstHiddenNodes, unsigned int);
98  itkGetConstReferenceMacro(NumOfFirstHiddenNodes, unsigned int);
99 
100  itkSetMacro(NumOfOutputNodes, unsigned int);
101  itkGetConstReferenceMacro(NumOfOutputNodes, unsigned int);
102 
103  itkSetMacro(FirstHiddenLayerBias, ValueType);
104  itkGetConstReferenceMacro(FirstHiddenLayerBias, ValueType);
105 
106  //#define __USE_OLD_INTERFACE Comment out to ensure that new interface works
107 #ifdef __USE_OLD_INTERFACE
108  //Original Function name before consistency naming changes
109  inline void SetNumOfHiddenNodes(const unsigned int & x) { SetNumOfFirstHiddenNodes(x); }
110  inline unsigned int GetNumOfHiddenNodes(void) const { return GetNumOfFirstHiddenNodes(); }
111  inline void SetHiddenLayerBias(const ValueType & bias) { SetFirstHiddenLayerBias(bias); }
112  ValueType GetHiddenLayerBias(void) const { return GetFirstHiddenLayerBias();}
113 #endif
114  itkSetMacro(OutputLayerBias, ValueType);
115  itkGetConstReferenceMacro(OutputLayerBias, ValueType);
116 
117  virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector);
118 
121 #ifdef __USE_OLD_INTERFACE
122  //Original Function name before consistency naming changes
123  inline void SetHiddenTransferFunction(TransferFunctionInterfaceType* f) { SetFirstHiddenTransferFunction (f); }
124 #endif
127 
128 protected:
129 
130  RBFNetwork();
131  virtual ~RBFNetwork(){};
132 
134  virtual void PrintSelf( std::ostream& os, Indent indent ) const;
135 
136 private:
137 
139  std::vector<TMeasurementVector> m_Centers; // ui....uc
140  std::vector<double> m_Radii;
141 
142  unsigned int m_Classes;
143  unsigned int m_NumOfInputNodes;
145  unsigned int m_NumOfOutputNodes;
146 
149 
150  typename InputFunctionInterfaceType::Pointer m_InputFunction;
151  typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
153  typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
154 };
155 
156 } // end namespace Statistics
157 } // end namespace itk
158 
159 #ifndef ITK_MANUAL_INSTANTIATION
160 #include "itkRBFNetwork.hxx"
161 #endif
162 
163 #endif
164