ITK  4.8.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 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;
54  typedef vnl_vector<ValueType> NodeVectorType;
60 
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 
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();
124 
126  virtual void PrintSelf( std::ostream& os, Indent indent ) const ITK_OVERRIDE;
127 
128 private:
129 
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
virtual ValueType Activation(ValueType) override
std::vector< InternalVectorType > m_Centers
Definition: itkRBFLayer.h:137
Light weight base class for most itk classes.
virtual void SetNumberOfNodes(unsigned int numNodes) override
virtual void BackwardPropagate() override
void SetInputValue(unsigned int i, ValueType value)
void SetRBF(RBFType *f)
SmartPointer< const Self > ConstPointer
Definition: itkRBFLayer.h:45
RBFType::Pointer m_RBF
Definition: itkRBFLayer.h:142
This is the itkRBFLayer class.
Definition: itkRBFLayer.h:39
NodeVectorType m_InputErrorValues
Definition: itkRBFLayer.h:132
virtual void PrintSelf(std::ostream &os, Indent indent) const override
RadialBasisFunctionBase< ValueType > RBFType
Definition: itkRBFLayer.h:68
SmartPointer< Self > Pointer
Definition: itkRBFLayer.h:44
Superclass::InputFunctionInterfaceType InputFunctionInterfaceType
Definition: itkRBFLayer.h:62
virtual void ForwardPropagate() override
virtual void SetOutputValue(unsigned int, ValueType)
Superclass::TransferFunctionInterfaceType TransferFunctionInterfaceType
Definition: itkRBFLayer.h:63
EuclideanDistanceMetric< InternalVectorType > DistanceMetricType
Definition: itkRBFLayer.h:66
virtual ValueType DActivation(ValueType) override
TTargetVector OutputVectorType
Definition: itkLayerBase.h:50
CompletelyConnectedWeightSet< TMeasurementVector, TTargetVector > WeightSetType
Definition: itkRBFLayer.h:59
NodeVectorType m_OutputErrorValues
Definition: itkRBFLayer.h:133
LayerBase< TMeasurementVector, TTargetVector > Superclass
Definition: itkRBFLayer.h:43
void SetRadii(ValueType c, unsigned int i)
TMeasurementVector::ValueType ValueType
Definition: itkLayerBase.h:52
void SetCenter(TMeasurementVector c, unsigned int i)
this class declares common interfaces for distance functions.
virtual ValueType * GetOutputVector() override
virtual ValueType GetInputValue(unsigned int i) const override
Superclass::LayerInterfaceType LayerInterfaceType
Definition: itkRBFLayer.h:57
Superclass::WeightSetInterfaceType WeightSetInterfaceType
Definition: itkRBFLayer.h:61
void SetOutputVector(TMeasurementVector value)
Superclass::ValueType ValueType
Definition: itkRBFLayer.h:49
InternalVectorType m_Radii
Definition: itkRBFLayer.h:138
virtual ValueType * GetInputErrorVector() override
DistanceMetricType::Pointer m_DistanceMetric
Definition: itkRBFLayer.h:135
vnl_vector< ValueType > NodeVectorType
Definition: itkLayerBase.h:55
virtual ValueType GetInputErrorValue(unsigned int node_id) const override
Superclass::OutputVectorType OutputVectorType
Definition: itkRBFLayer.h:56
NodeVectorType m_NodeOutputValues
Definition: itkRBFLayer.h:131
DistanceMetricType::Pointer DistanceMetricPointer
Definition: itkRBFLayer.h:67
virtual ValueType GetOutputValue(unsigned int) const override
virtual ValueType GetOutputErrorValue(unsigned int node_id) const override
ValueType GetRadii(unsigned int i) const
NodeVectorType m_NodeInputValues
Definition: itkRBFLayer.h:130
This is the itkCompletelyConnectedWeightSet class.
InternalVectorType GetCenter(unsigned int i) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Array< ValueType > InternalVectorType
Definition: itkLayerBase.h:56
InputFunctionBase< ValueType *, ValueType > InputFunctionInterfaceType
Definition: itkLayerBase.h:61
WeightSetBase< TMeasurementVector, TTargetVector > WeightSetInterfaceType
Definition: itkLayerBase.h:60
virtual void SetOutputErrorValues(TTargetVector) override
void SetDistanceMetric(DistanceMetricType *f)
Superclass::ValuePointer ValuePointer
Definition: itkRBFLayer.h:53
void SetRBF_Dim(unsigned int size)
Superclass::InternalVectorType InternalVectorType
Definition: itkRBFLayer.h:55
TransferFunctionBase< ValueType > TransferFunctionInterfaceType
Definition: itkLayerBase.h:62
virtual void SetInputErrorValue(ValueType, unsigned int node_id) override
This is the itkRadialBasisFunctionBase class.