ITK  4.6.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<typename TMeasurementVector, typename 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
Array class with size defined at construction time.
Definition: itkArray.h:50
Superclass::MeasurementVectorType MeasurementVectorType
Definition: itkRBFNetwork.h:58
MultilayerNeuralNetworkBase< TMeasurementVector, TTargetVector, BackPropagationLayer< TMeasurementVector, TTargetVector > > Superclass
Definition: itkRBFNetwork.h:53
Superclass::WeightVectorType WeightVectorType
Definition: itkRBFNetwork.h:65
Array< ValueType > ArrayType
Definition: itkRBFNetwork.h:72
std::vector< double > m_Radii
This is the itkRBFLayer class.
Definition: itkRBFLayer.h:39
RadialBasisFunctionBase< ValueType > RBFTransferFunctionType
Definition: itkRBFNetwork.h:74
Superclass::LearningLayerType LearningLayerType
Definition: itkRBFNetwork.h:63
void SetInputFunction(InputFunctionInterfaceType *f)
SmartPointer< Self > Pointer
Definition: itkRBFNetwork.h:54
virtual void SetNumOfFirstHiddenNodes(unsigned int _arg)
void SetRadius(ValueType r)
virtual NetworkOutputType GenerateOutput(TMeasurementVector samplevector)
Superclass::ValueType ValueType
Definition: itkRBFNetwork.h:57
TransferFunctionInterfaceType::Pointer m_InputTransferFunction
void SetOutputTransferFunction(TransferFunctionInterfaceType *f)
Superclass::LayerVectorType LayerVectorType
Definition: itkRBFNetwork.h:66
RBFTransferFunctionType::Pointer m_FirstHiddenTransferFunction
MeasurementVectorType::ValueType ValueType
Superclass::NetworkOutputType NetworkOutputType
Definition: itkRBFNetwork.h:60
unsigned int m_NumOfFirstHiddenNodes
void SetFirstHiddenTransferFunction(TransferFunctionInterfaceType *f)
This is the itkMultilayerNeuralNetworkBase class.
std::vector< TMeasurementVector > m_Centers
void SetDistanceMetric(DistanceMetricType *f)
TransferFunctionInterfaceType::Pointer m_OutputTransferFunction
EuclideanDistanceMetric< ArrayType > DistanceMetricType
Definition: itkRBFNetwork.h:73
virtual const unsigned int & GetNumOfFirstHiddenNodes() const
SmartPointer< const Self > ConstPointer
Definition: itkRBFNetwork.h:55
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void PrintSelf(std::ostream &os, Indent indent) const
Superclass::TargetVectorType TargetVectorType
Definition: itkRBFNetwork.h:59
This is the itkRBFNetwork class.
Definition: itkRBFNetwork.h:47
DistanceMetricType::Pointer m_DistanceMetric
Superclass::InputFunctionInterfaceType InputFunctionInterfaceType
Definition: itkRBFNetwork.h:69
void SetCenter(TMeasurementVector c)
Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType
Definition: itkRBFNetwork.h:68
void SetInputTransferFunction(TransferFunctionInterfaceType *f)
virtual void SetFirstHiddenLayerBias(ValueType _arg)
InputFunctionInterfaceType::Pointer m_InputFunction
Base class for all data objects in ITK.
RBFLayer< TMeasurementVector, TTargetVector > HiddenLayerType
Definition: itkRBFNetwork.h:75
This is the itkRadialBasisFunctionBase class.
virtual const ValueType & GetFirstHiddenLayerBias() const
Superclass::LayerInterfaceType LayerInterfaceType
Definition: itkRBFNetwork.h:62