00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkBackPropagationLayer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/08/02 19:17:37 $ 00007 Version: $Revision: 1.1 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkBackPropagationLayerBase_h 00018 #define __itkBackPropagationLayerBase_h 00019 00020 #include "itkLayerBase.h" 00021 #include "itkObject.h" 00022 #include "itkMacro.h" 00023 00024 namespace itk 00025 { 00026 namespace Statistics 00027 { 00028 template<class TVector, class TOutput> 00029 class BackPropagationLayer : public LayerBase<TVector, TOutput> 00030 { 00031 public: 00032 typedef BackPropagationLayer Self; 00033 typedef LayerBase<TVector, TOutput> Superclass; 00034 typedef SmartPointer<Self> Pointer; 00035 typedef SmartPointer<const Self> ConstPointer; 00036 00038 itkTypeMacro(BackPropagationLayer, LayerBase); 00039 itkNewMacro(Self); 00040 00041 typedef typename Superclass::ValueType ValueType; 00042 typedef typename Superclass::ValuePointer ValuePointer; 00043 typedef vnl_vector<ValueType> NodeVectorType; 00044 00045 typedef typename Superclass::OutputVectorType OutputVectorType; 00046 00047 //Member Functions 00048 void SetNumberOfNodes(unsigned int); 00049 ValueType GetInputValue(unsigned int i); 00050 void SetInputValue(unsigned int i, ValueType value); 00051 00052 ValueType GetOutputValue(int); 00053 void SetOutputValue(int, ValueType); 00054 00055 ValuePointer GetOutputVector(); 00056 void SetOutputVector(TVector value); 00057 00058 void ForwardPropagate(); 00059 void ForwardPropagate(TVector); 00060 00061 void BackwardPropagate(TOutput e); 00062 void BackwardPropagate(); 00063 00064 void SetOutputErrorValues(TOutput); 00065 ValueType GetOutputErrorValue(unsigned int); 00066 00067 ValueType GetInputErrorValue(int); 00068 ValuePointer GetInputErrorVector(); 00069 void SetInputErrorValue(ValueType, int); 00070 00071 ValueType Activation(ValueType); 00072 ValueType DActivation(ValueType); 00073 00075 void SetBias(ValueType b); 00076 ValueType GetBias(); 00077 00078 protected: 00079 00080 BackPropagationLayer(); 00081 ~BackPropagationLayer(); 00082 00084 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00085 00086 private: 00087 00088 NodeVectorType m_NodeInputValues; 00089 NodeVectorType m_NodeOutputValues; 00090 NodeVectorType m_InputErrorValues; 00091 NodeVectorType m_OutputErrorValues; 00092 ValueType m_Bias; 00093 }; 00094 00095 } // end namespace Statistics 00096 } // end namespace itk 00097 00098 #ifndef ITK_MANUAL_INSTANTIATION 00099 #include "itkBackPropagationLayer.txx" 00100 #endif 00101 00102 #endif