00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNeuralNetworkFileReader.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/02/13 19:03:13 $ 00007 Version: $Revision: 1.8 $ 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 00018 #ifndef __itkNeuralNetworkFileReader_h 00019 #define __itkNeuralNetworkFileReader_h 00020 00021 #include "metaTypes.h" 00022 #include "metaUtils.h" 00023 00024 #include "itkMultilayerNeuralNetworkBase.h" 00025 00026 #include "itkBackPropagationLayer.h" 00027 00028 #include "itkCompletelyConnectedWeightSet.h" 00029 00030 #include "itkSumInputFunction.h" 00031 #include "itkProductInputFunction.h" 00032 00033 #include "itkIdentityTransferFunction.h" 00034 #include "itkLogSigmoidTransferFunction.h" 00035 #include "itkSigmoidTransferFunction.h" 00036 #include "itkTanSigmoidTransferFunction.h" 00037 #include "itkSymmetricSigmoidTransferFunction.h" 00038 00039 00040 namespace itk 00041 { 00042 00062 template<class TVector, class TOutput> 00063 class NeuralNetworkFileReader : public Object 00064 { 00065 public: 00066 00068 typedef NeuralNetworkFileReader Self; 00069 typedef Object Superclass; 00070 typedef SmartPointer<Self> Pointer; 00071 typedef SmartPointer<const Self> ConstPointer; 00072 00074 itkTypeMacro(NeuralNetworkFileReader,Object); 00075 00077 itkNewMacro(Self); 00078 00079 typedef Statistics::MultilayerNeuralNetworkBase<TVector,TOutput> NetworkType; 00080 typedef typename NetworkType::Pointer NetworkPointer; 00081 00082 typedef Statistics::LayerBase<TVector,TOutput> LayerType; 00083 typedef typename LayerType::Pointer LayerPointer; 00084 00085 typedef typename LayerType::ValueType ValueType; 00086 00087 typedef typename NetworkType::WeightSetType WeightSetType; 00088 typedef Statistics::CompletelyConnectedWeightSet<TVector, TOutput> 00089 CompletelyConnectedWeighttype; 00090 00091 typedef Statistics::BackPropagationLayer<TVector,TOutput> BackPropLayerType; 00092 typedef typename BackPropLayerType::Pointer BPLayerPointerType; 00093 00094 typedef typename CompletelyConnectedWeighttype::Pointer 00095 CompletelyWeightSetPointer; 00096 00097 typedef typename WeightSetType::Pointer WeightSetPointer; 00098 00100 itkSetStringMacro( FileName ); 00101 00103 itkGetStringMacro( FileName ); 00104 00106 void Update(void); 00107 00108 NetworkType * GetOutput() const; 00109 00110 itkSetMacro( ReadWeightValuesType, unsigned int ); 00111 itkGetConstMacro( ReadWeightValuesType, unsigned int ); 00112 00113 00114 protected: 00115 NeuralNetworkFileReader(); 00116 virtual ~NeuralNetworkFileReader(); 00117 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00118 00119 private: 00120 00121 void ClearFields(); 00122 typedef std::vector<MET_FieldRecordType *> FieldsContainerType; 00123 typedef std::vector< LayerPointer > LayersContainer; 00124 typedef std::vector<WeightSetPointer> WeightsContainer; 00125 00126 typedef struct 00127 { 00128 std::string name; 00129 std::string value; 00130 } LineType; 00131 00132 typedef std::list< LineType > LinesContainer; 00133 00134 00135 NetworkPointer m_Network; 00136 int m_ReadWeightValuesType; 00137 LayersContainer m_Layers; 00138 WeightsContainer m_Weights; 00139 LinesContainer m_NameValue; 00140 std::string m_FileName; 00141 FieldsContainerType m_Fields; 00142 std::ifstream m_InputFile; 00143 00144 }; 00145 00146 } // namespace itk 00147 00148 #ifndef ITK_MANUAL_INSTANTIATION 00149 #include "itkNeuralNetworkFileReader.txx" 00150 #endif 00151 00152 #endif 00153