ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkRBFLayer.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 itkRBFLayer_h
19 #define itkRBFLayer_h
20 
22 #include "itkLayerBase.h"
23 #include "itkObject.h"
24 #include "itkMacro.h"
27 
28 namespace itk
29 {
30 namespace Statistics
31 {
38 template<typename TMeasurementVector, typename TTargetVector>
39 class ITK_TEMPLATE_EXPORT RBFLayer : public LayerBase<TMeasurementVector, TTargetVector>
40 {
41 public:
42  typedef RBFLayer Self;
46 
48  itkTypeMacro(RBFLayer, LayerBase);
49  itkNewMacro(Self);
51 
52  typedef typename Superclass::ValueType ValueType;
53  typedef typename Superclass::ValuePointer ValuePointer;
54  typedef vnl_vector<ValueType> NodeVectorType;
55  typedef typename Superclass::InternalVectorType InternalVectorType;
56  typedef typename Superclass::OutputVectorType OutputVectorType;
57  typedef typename Superclass::LayerInterfaceType LayerInterfaceType;
60 
61  typedef typename Superclass::WeightSetInterfaceType WeightSetInterfaceType;
62  typedef typename Superclass::InputFunctionInterfaceType InputFunctionInterfaceType;
63  typedef typename Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType;
64 
65  //Distance Metric
69 
70  //Member Functions
71  itkGetConstReferenceMacro(RBF_Dim, unsigned int);
72  void SetRBF_Dim(unsigned int size);
73  virtual void SetNumberOfNodes(unsigned int numNodes) ITK_OVERRIDE;
74  virtual ValueType GetInputValue(unsigned int i) const ITK_OVERRIDE;
75  void SetInputValue(unsigned int i, ValueType value);
76 
77  virtual ValueType GetOutputValue(unsigned int) const ITK_OVERRIDE;
78  virtual void SetOutputValue(unsigned int, ValueType);
79 
80  virtual ValueType * GetOutputVector() ITK_OVERRIDE;
81  void SetOutputVector(TMeasurementVector value);
82 
83  virtual void ForwardPropagate() ITK_OVERRIDE;
84  virtual void ForwardPropagate(TMeasurementVector input) ITK_OVERRIDE;
85 
86  virtual void BackwardPropagate() ITK_OVERRIDE;
87  virtual void BackwardPropagate(TTargetVector itkNotUsed(errors)) ITK_OVERRIDE {};
88 
89  virtual void SetOutputErrorValues(TTargetVector) ITK_OVERRIDE;
90  virtual ValueType GetOutputErrorValue(unsigned int node_id) const ITK_OVERRIDE;
91 
92  virtual ValueType GetInputErrorValue(unsigned int node_id) const ITK_OVERRIDE;
93  virtual ValueType * GetInputErrorVector() ITK_OVERRIDE;
94  virtual void SetInputErrorValue(ValueType, unsigned int node_id) ITK_OVERRIDE;
95 
96  //TMeasurementVector GetCenter(int i);
97  InternalVectorType GetCenter(unsigned int i) const;
98  void SetCenter(TMeasurementVector c,unsigned int i);
99 
100  ValueType GetRadii(unsigned int i) const;
101  void SetRadii(ValueType c,unsigned int i);
102 
103  virtual ValueType Activation(ValueType) ITK_OVERRIDE;
104  virtual ValueType DActivation(ValueType) ITK_OVERRIDE;
105 
107  itkSetMacro( Bias, ValueType );
108  itkGetConstReferenceMacro( Bias, ValueType );
110 
111  void SetDistanceMetric(DistanceMetricType* f);
112  itkGetModifiableObjectMacro(DistanceMetric, DistanceMetricType );
113 
114  itkSetMacro(NumClasses,unsigned int);
115  itkGetConstReferenceMacro(NumClasses,unsigned int);
116 
117  void SetRBF(RBFType* f);
118  itkGetModifiableObjectMacro(RBF, RBFType);
119 
120 protected:
121 
122  RBFLayer();
123  virtual ~RBFLayer() ITK_OVERRIDE;
124 
126  virtual void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
127 
128 private:
129 
130  NodeVectorType m_NodeInputValues;
131  NodeVectorType m_NodeOutputValues;
132  NodeVectorType m_InputErrorValues;
133  NodeVectorType m_OutputErrorValues;
134 
135  typename DistanceMetricType::Pointer m_DistanceMetric;
136 
137  std::vector<InternalVectorType> m_Centers; // ui....uc
139  unsigned int m_NumClasses;
140  ValueType m_Bias;
141  unsigned int m_RBF_Dim;
142  typename RBFType::Pointer m_RBF;
143 };
144 
145 } // end namespace Statistics
146 } // end namespace itk
147 
148 #ifndef ITK_MANUAL_INSTANTIATION
149 #include "itkRBFLayer.hxx"
150 #endif
151 
152 #endif
Array class with size defined at construction time.
Definition: itkArray.h:50
This is the itkLayerBase class.
Definition: itkLayerBase.h:38
vnl_vector< ValueType > NodeVectorType
Definition: itkRBFLayer.h:54
Light weight base class for most itk classes.
SmartPointer< const Self > ConstPointer
Definition: itkRBFLayer.h:45
This is the itkRBFLayer class.
Definition: itkRBFLayer.h:39
RadialBasisFunctionBase< ValueType > RBFType
Definition: itkRBFLayer.h:68
SmartPointer< Self > Pointer
Definition: itkRBFLayer.h:44
Superclass::InputFunctionInterfaceType InputFunctionInterfaceType
Definition: itkRBFLayer.h:62
Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType
Definition: itkRBFLayer.h:63
EuclideanDistanceMetric< InternalVectorType > DistanceMetricType
Definition: itkRBFLayer.h:66
CompletelyConnectedWeightSet< TMeasurementVector, TTargetVector > WeightSetType
Definition: itkRBFLayer.h:59
LayerBase< TMeasurementVector, TTargetVector > Superclass
Definition: itkRBFLayer.h:43
TMeasurementVector::ValueType ValueType
Definition: itkLayerBase.h:52
this class declares common interfaces for distance functions.
Superclass::LayerInterfaceType LayerInterfaceType
Definition: itkRBFLayer.h:57
Superclass::WeightSetInterfaceType WeightSetInterfaceType
Definition: itkRBFLayer.h:61
Superclass::ValueType ValueType
Definition: itkRBFLayer.h:49
vnl_vector< ValueType > NodeVectorType
Definition: itkLayerBase.h:55
Superclass::OutputVectorType OutputVectorType
Definition: itkRBFLayer.h:56
DistanceMetricType::Pointer DistanceMetricPointer
Definition: itkRBFLayer.h:67
This is the itkCompletelyConnectedWeightSet class.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Superclass::ValuePointer ValuePointer
Definition: itkRBFLayer.h:53
Superclass::InternalVectorType InternalVectorType
Definition: itkRBFLayer.h:55
This is the itkRadialBasisFunctionBase class.