Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkNeuralNetworkFileWriter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Insight Segmentation & Registration Toolkit
00004 Module:    $RCSfile: itkNeuralNetworkFileWriter.h,v $
00005 Language:  C++
00006 Date:      $Date: 2008-02-07 15:58:06 $
00007 Version:   $Revision: 1.14 $
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 #include "itkOneHiddenLayerBackPropagationNeuralNetwork.h"
00027 #include "itkTwoHiddenLayerBackPropagationNeuralNetwork.h"
00028 
00029 #include "itkBackPropagationLayer.h"
00030 #include "itkCompletelyConnectedWeightSet.h"
00031 
00032 #include "itkSumInputFunction.h"
00033 #include "itkProductInputFunction.h"
00034 
00035 #include "itkIdentityTransferFunction.h"
00036 #include "itkLogSigmoidTransferFunction.h"
00037 #include "itkSigmoidTransferFunction.h"
00038 #include "itkTanSigmoidTransferFunction.h"
00039 #include "itkSymmetricSigmoidTransferFunction.h"
00040 
00041 
00042 namespace itk
00043 {
00065 template<class TNetwork>
00066 class NeuralNetworkFileWriter : public Object
00067 {
00068 public:
00069 
00071   typedef NeuralNetworkFileWriter           Self;
00072   typedef Object                            Superclass;
00073   typedef SmartPointer<Self>                Pointer;
00074   typedef SmartPointer<const Self>          ConstPointer;
00075 
00077   itkTypeMacro(NeuralNetworkFileWriter,Object);
00078 
00080   itkNewMacro(Self);
00081 
00082   typedef typename TNetwork::MeasurementVectorType   MeasurementVectorType;
00083   typedef typename TNetwork::TargetVectorType        TargetVectorType;
00084 
00085   typedef Statistics::LayerBase< 
00086     MeasurementVectorType, TargetVectorType >        LayerBaseType;
00087   typedef typename LayerBaseType::Pointer            LayerBasePointer;
00088   typedef typename LayerBaseType::ConstPointer       LayerBaseConstPointer;
00089 
00090 //   typedef typename TNetwork::Pointer                       NetworkPointer;
00091 //   typedef typename TNetwork::ConstPointer                  NetworkConstPointer;
00092 
00093 // typedef typename TNetwork::LayerType                     LayerType;
00094 // typedef typename LayerType::Pointer                      LayerPointer;
00095 // typedef typename LayerType::ConstPointer                 LayerConstPointer;
00096 // typedef typename LayerType::TransferFunctionType::Pointer      TransferFunctionPointer;
00097 // typedef typename LayerType::TransferFunctionType::ConstPointer TransferFunctionConstPointer;
00098 
00099 // typedef typename LayerType::InputFunctionType::Pointer         InputFunctionPointer;
00100 // typedef typename LayerType::InputFunctionType::ConstPointer    InputFunctionConstPointer;
00101 
00102 // typedef typename LayerType::WeightSetType                WeightSetType;
00103 // typedef typename LayerType::WeightSetPointer             WeightSetPointer;
00104 // typedef typename LayerType::WeightSetConstPointer        WeightSetConstPointer;
00105 //  typedef typename LayerType::ValueType                    ValueType;
00106 
00108   itkSetStringMacro(FileName);
00109 
00111   itkGetStringMacro(FileName);
00112 
00114   //Avoiding VS6 compiler error void SetInput( const TNetwork* network );
00115   void SetInput( TNetwork* network );
00116   const TNetwork * GetInput() const;
00118 
00120   void Update(void);
00121 
00122 #ifdef IGNORE
00123 #undef IGNORE
00124 #endif
00125  //ASCII only works for very small networks (i.e. less than 256 weights),
00126  //and the MetaIO mechanism is not desigend for the way that this is used
00127  //to write these files out.
00128  // Comment this code out until it can be robustly written.
00129   typedef enum { IGNORE=0, ASCII=1, BINARY=2 } NetworkWriteWeightsType;
00130   itkSetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
00131   itkGetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
00132 
00133 protected:
00134   NeuralNetworkFileWriter();
00135   ~NeuralNetworkFileWriter();
00136   virtual void PrintSelf( std::ostream& os, Indent indent ) const;
00137 
00138 private:
00139   void ClearFields();
00140   typedef std::vector<MET_FieldRecordType *> FieldsContainerType;
00141 
00142   //Attempting to avoid VS 6 compiler error typename TNetwork::ConstPointer     m_Network;
00143   typename TNetwork::Pointer     m_Network;
00144   NetworkWriteWeightsType        m_WriteWeightValuesType;
00145 
00146   std::string                    m_FileName;
00147   FieldsContainerType            m_Fields;
00148 
00149   std::ofstream                  m_OutputFile;
00150 };
00151 
00152 } // namespace itk
00153 
00154 #ifndef ITK_MANUAL_INSTANTIATION
00155 #include "itkNeuralNetworkFileWriter.txx"
00156 #endif
00157 
00158 #endif
00159 

Generated at Fri Apr 16 19:11:03 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000