00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNeuralNetworkFileWriter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2007/02/13 21:37:03 $ 00007 Version: $Revision: 1.7 $ 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 __itkNeuralNetworkFileWriter_h 00019 #define __itkNeuralNetworkFileWriter_h 00020 00021 #include <metaTypes.h> 00022 #include <metaUtils.h> 00023 #include <typeinfo> 00024 00025 #include "itkMultilayerNeuralNetworkBase.h" 00026 00027 #include "itkBackPropagationLayer.h" 00028 00029 #include "itkCompletelyConnectedWeightSet.h" 00030 00031 #include "itkSumInputFunction.h" 00032 #include "itkProductInputFunction.h" 00033 00034 #include "itkIdentityTransferFunction.h" 00035 #include "itkLogSigmoidTransferFunction.h" 00036 #include "itkSigmoidTransferFunction.h" 00037 #include "itkTanSigmoidTransferFunction.h" 00038 #include "itkSymmetricSigmoidTransferFunction.h" 00039 00040 00041 namespace itk 00042 { 00064 template<class TVector, class TOutput> 00065 class NeuralNetworkFileWriter : public Object 00066 { 00067 public: 00068 00070 typedef NeuralNetworkFileWriter Self; 00071 typedef Object Superclass; 00072 typedef SmartPointer<Self> Pointer; 00073 typedef SmartPointer<const Self> ConstPointer; 00074 00076 itkTypeMacro(NeuralNetworkFileWriter,Object); 00077 00079 itkNewMacro(Self); 00080 00081 typedef Statistics::MultilayerNeuralNetworkBase<TVector,TOutput> NetworkType; 00082 00083 typedef typename NetworkType::Pointer NetworkPointer; 00084 typedef typename NetworkType::ConstPointer NetworkConstPointer; 00085 00086 typedef Statistics::LayerBase<TVector,TOutput> LayerType; 00087 00088 typedef typename LayerType::Pointer LayerPointer; 00089 typedef typename LayerType::ConstPointer LayerConstPointer; 00090 00091 typedef typename LayerType::TransferFunctionPointer TransferFunctionPointer; 00092 00093 typedef typename LayerType::TransferFunctionConstPointer 00094 TransferFunctionConstPointer; 00095 00096 typedef typename LayerType::InputFunctionPointer InputFunctionPointer; 00097 00098 typedef typename LayerType::InputFunctionConstPointer 00099 InputFunctionConstPointer; 00100 00101 typedef typename LayerType::WeightSetPointer WeightSetPointer; 00102 typedef typename LayerType::WeightSetConstPointer WeightSetConstPointer; 00103 typedef typename LayerType::ValueType ValueType; 00104 00105 typedef typename NetworkType::WeightSetType WeightSetType; 00106 typedef Statistics::BackPropagationLayer<TVector,TOutput> BackPropLayerType; 00107 typedef typename BackPropLayerType::Pointer BPLayerPointerType; 00108 00110 itkSetStringMacro(FileName); 00111 00113 itkGetStringMacro(FileName); 00114 00116 void SetInput( const NetworkType* network ); 00117 const NetworkType * GetInput() const; 00119 00121 void Update(void); 00122 00123 itkSetMacro(WriteWeightValuesType, unsigned int); 00124 itkGetConstMacro(WriteWeightValuesType, unsigned int); 00125 00126 protected: 00127 NeuralNetworkFileWriter(); 00128 virtual ~NeuralNetworkFileWriter(); 00129 virtual void PrintSelf( std::ostream& os, Indent indent ) const; 00130 00131 private: 00132 void ClearFields(); 00133 typedef std::vector<MET_FieldRecordType *> FieldsContainerType; 00134 00135 NetworkConstPointer m_Network; 00136 unsigned int m_WriteWeightValuesType; 00137 00138 std::string m_FileName; 00139 FieldsContainerType m_Fields; 00140 00141 std::ofstream m_OutputFile; 00142 }; 00143 00144 } // namespace itk 00145 00146 #ifndef ITK_MANUAL_INSTANTIATION 00147 #include "itkNeuralNetworkFileWriter.txx" 00148 #endif 00149 00150 #endif 00151