00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkBackPropagationLayer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006/04/17 21:34:31 $ 00007 Version: $Revision: 1.3 $ 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); 00041 00042 typedef typename Superclass::ValueType ValueType; 00043 typedef typename Superclass::ValuePointer ValuePointer; 00044 typedef vnl_vector<ValueType> NodeVectorType; 00045 typedef typename Superclass::InternalVectorType InternalVectorType; 00046 typedef typename Superclass::OutputVectorType OutputVectorType; 00047 00048 //Member Functions 00049 void SetNumberOfNodes(unsigned int); 00050 ValueType GetInputValue(unsigned int i); 00051 void SetInputValue(unsigned int i, ValueType value); 00052 00053 ValueType GetOutputValue(int); 00054 void SetOutputValue(int, ValueType); 00055 00056 ValuePointer GetOutputVector(); 00057 void SetOutputVector(TVector value); 00058 00059 void ForwardPropagate(); 00060 void ForwardPropagate(TVector); 00061 00062 void BackwardPropagate(InternalVectorType e); 00063 void BackwardPropagate(); 00064 00065 void SetOutputErrorValues(TOutput); 00066 ValueType GetOutputErrorValue(unsigned int); 00067 00068 ValueType GetInputErrorValue(int); 00069 ValuePointer GetInputErrorVector(); 00070 void SetInputErrorValue(ValueType, int); 00071 00072 ValueType Activation(ValueType); 00073 ValueType DActivation(ValueType); 00074 00076 void SetBias(ValueType b); 00077 ValueType GetBias(); 00079 00080 protected: 00081 00082 BackPropagationLayer(); 00083 ~BackPropagationLayer(); 00084 00086 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00087 00088 private: 00089 00090 NodeVectorType m_NodeInputValues; 00091 NodeVectorType m_NodeOutputValues; 00092 NodeVectorType m_InputErrorValues; 00093 NodeVectorType m_OutputErrorValues; 00094 ValueType m_Bias; 00095 }; 00096 00097 } // end namespace Statistics 00098 } // end namespace itk 00099 00100 #ifndef ITK_MANUAL_INSTANTIATION 00101 #include "itkBackPropagationLayer.txx" 00102 #endif 00103 00104 #endif 00105