ITK  4.2.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 protected:
128 
129  RBFNetwork();
130  virtual ~RBFNetwork(){};
131 
133  virtual void PrintSelf( std::ostream& os, Indent indent ) const;
134 
135 private:
136 
138  std::vector<TMeasurementVector> m_Centers; // ui....uc
139  std::vector<double> m_Radii;
140 
141  unsigned int m_Classes;
142  unsigned int m_NumOfInputNodes;
144  unsigned int m_NumOfOutputNodes;
145 
148 
149  typename InputFunctionInterfaceType::Pointer m_InputFunction;
150  typename TransferFunctionInterfaceType::Pointer m_InputTransferFunction;
152  typename TransferFunctionInterfaceType::Pointer m_OutputTransferFunction;
153 };
154 
155 } // end namespace Statistics
156 } // end namespace itk
157 
158 #ifndef ITK_MANUAL_INSTANTIATION
159 #include "itkRBFNetwork.hxx"
160 #endif
161 
162 #endif
163