ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkBackPropagationLayer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkBackPropagationLayer_h
00019 #define __itkBackPropagationLayer_h
00020 
00021 #include "itkCompletelyConnectedWeightSet.h"
00022 #include "itkLayerBase.h"
00023 #include "itkObject.h"
00024 #include "itkMacro.h"
00025 
00026 namespace itk
00027 {
00028 namespace Statistics
00029 {
00036 template<class TMeasurementVector, class TTargetVector>
00037 class BackPropagationLayer : public LayerBase<TMeasurementVector, TTargetVector>
00038 {
00039 public:
00040   typedef BackPropagationLayer                         Self;
00041   typedef LayerBase<TMeasurementVector, TTargetVector> Superclass;
00042   typedef SmartPointer<Self>                           Pointer;
00043   typedef SmartPointer<const Self>                     ConstPointer;
00044 
00046   itkTypeMacro(BackPropagationLayer, LayerBase);
00047   itkNewMacro(Self);
00049 
00050   typedef typename Superclass::ValueType              ValueType;
00051   typedef vnl_vector<ValueType>                       NodeVectorType;
00052   typedef typename Superclass::InternalVectorType     InternalVectorType;
00053   typedef typename Superclass::OutputVectorType       OutputVectorType;
00054   typedef typename Superclass::LayerInterfaceType     LayerInterfaceType;
00055   typedef CompletelyConnectedWeightSet<TMeasurementVector,TTargetVector>
00056                                                       WeightSetType;
00057 
00058   typedef typename Superclass::WeightSetInterfaceType WeightSetInterfaceType;
00059   typedef typename Superclass::InputFunctionInterfaceType
00060                                                       InputFunctionInterfaceType;
00061   typedef typename Superclass::TransferFunctionInterfaceType
00062                                                       TransferFunctionInterfaceType;
00063   //Member Functions
00064   virtual void SetNumberOfNodes(unsigned int numNodes);
00065   virtual ValueType GetInputValue(unsigned int i) const;
00066   virtual void SetInputValue(unsigned int i, ValueType value);
00067 
00068   virtual ValueType GetOutputValue(unsigned int) const;
00069   virtual void SetOutputValue(unsigned int, ValueType);
00070 
00071   virtual ValueType * GetOutputVector();
00072   void SetOutputVector(TMeasurementVector value);
00073 
00074   virtual void ForwardPropagate();
00075   virtual void ForwardPropagate(TMeasurementVector input);
00076 
00077   virtual void BackwardPropagate();
00078   virtual void BackwardPropagate(InternalVectorType errors);
00079 
00080   virtual void SetOutputErrorValues(TTargetVector);
00081   virtual ValueType GetOutputErrorValue(unsigned int node_id) const;
00082 
00083   virtual ValueType GetInputErrorValue(unsigned int node_id) const;
00084   virtual ValueType * GetInputErrorVector();
00085   virtual void SetInputErrorValue(ValueType, unsigned int node_id);
00086 
00087   virtual ValueType Activation(ValueType);
00088   virtual ValueType DActivation(ValueType);
00089 
00091   itkSetMacro( Bias, ValueType );
00092   itkGetConstReferenceMacro( Bias, ValueType );
00094 
00095 protected:
00096 
00097   BackPropagationLayer();
00098   virtual ~BackPropagationLayer();
00099 
00101   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00102 
00103 private:
00104 
00105   NodeVectorType   m_NodeInputValues;
00106   NodeVectorType   m_NodeOutputValues;
00107   NodeVectorType   m_InputErrorValues;
00108   NodeVectorType   m_OutputErrorValues;
00109   ValueType        m_Bias;
00110 };
00111 
00112 } // end namespace Statistics
00113 } // end namespace itk
00114 
00115 #ifndef ITK_MANUAL_INSTANTIATION
00116 #include "itkBackPropagationLayer.hxx"
00117 #endif
00118 
00119 #endif
00120