/usr/include/InsightToolkit/Review/itkNeuralNetworkFileWriter.h is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkNeuralNetworkFileWriter.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkNeuralNetworkFileWriter_h
#define __itkNeuralNetworkFileWriter_h
#include <metaTypes.h>
#include <metaUtils.h>
#include <typeinfo>
#include "itkMultilayerNeuralNetworkBase.h"
#include "itkOneHiddenLayerBackPropagationNeuralNetwork.h"
#include "itkTwoHiddenLayerBackPropagationNeuralNetwork.h"
#include "itkBackPropagationLayer.h"
#include "itkCompletelyConnectedWeightSet.h"
#include "itkSumInputFunction.h"
#include "itkProductInputFunction.h"
#include "itkIdentityTransferFunction.h"
#include "itkLogSigmoidTransferFunction.h"
#include "itkSigmoidTransferFunction.h"
#include "itkTanSigmoidTransferFunction.h"
#include "itkSymmetricSigmoidTransferFunction.h"
namespace itk
{
/** \class NeuralNetworkFileWriter
* \brief Writer for Neural Network
*
* This class will enable a user to save a trained neural network to a text
* file. The user can also change the network topology by editing the network
* configuration file.
*
* This class was contributed to the Insight Journal by Raghu Venkatram
* The original paper can be found at
* http://insight-journal.org/midas/handle.php?handle=1926/203
*
*
* \author Raghu Venkatram
*
* \sa NeuralNetworkFileReader
* \sa MultilayerNeuralNetworkBase
*
*
* \group IOFilter
*
*/
template<class TNetwork>
class NeuralNetworkFileWriter : public Object
{
public:
/** SmartPointer typedef support */
typedef NeuralNetworkFileWriter Self;
typedef Object Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Run-time type information (and related methods). */
itkTypeMacro(NeuralNetworkFileWriter,Object);
/** Method for creation through the object factory */
itkNewMacro(Self);
typedef typename TNetwork::MeasurementVectorType MeasurementVectorType;
typedef typename TNetwork::TargetVectorType TargetVectorType;
typedef Statistics::LayerBase<
MeasurementVectorType, TargetVectorType > LayerBaseType;
typedef typename LayerBaseType::Pointer LayerBasePointer;
typedef typename LayerBaseType::ConstPointer LayerBaseConstPointer;
// typedef typename TNetwork::Pointer NetworkPointer;
// typedef typename TNetwork::ConstPointer NetworkConstPointer;
// typedef typename TNetwork::LayerType LayerType;
// typedef typename LayerType::Pointer LayerPointer;
// typedef typename LayerType::ConstPointer LayerConstPointer;
// typedef typename LayerType::TransferFunctionType::Pointer TransferFunctionPointer;
// typedef typename LayerType::TransferFunctionType::ConstPointer TransferFunctionConstPointer;
// typedef typename LayerType::InputFunctionType::Pointer InputFunctionPointer;
// typedef typename LayerType::InputFunctionType::ConstPointer InputFunctionConstPointer;
// typedef typename LayerType::WeightSetType WeightSetType;
// typedef typename LayerType::WeightSetPointer WeightSetPointer;
// typedef typename LayerType::WeightSetConstPointer WeightSetConstPointer;
// typedef typename LayerType::ValueType ValueType;
/** Set the filename */
itkSetStringMacro(FileName);
/** Get the filename */
itkGetStringMacro(FileName);
/** Set/Get the input transform to write */
//Avoiding VS6 compiler error void SetInput( const TNetwork* network );
void SetInput( TNetwork* network );
const TNetwork * GetInput() const;
/** Read NeuralNetwork */
void Update(void);
#ifdef IGNORE
#undef IGNORE
#endif
//ASCII only works for very small networks (i.e. less than 256 weights),
//and the MetaIO mechanism is not desigend for the way that this is used
//to write these files out.
// Comment this code out until it can be robustly written.
typedef enum { IGNORE=0, ASCII=1, BINARY=2 } NetworkWriteWeightsType;
itkSetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
itkGetEnumMacro(WriteWeightValuesType, NetworkWriteWeightsType);
protected:
NeuralNetworkFileWriter();
~NeuralNetworkFileWriter();
virtual void PrintSelf( std::ostream& os, Indent indent ) const;
private:
void ClearFields();
typedef std::vector<MET_FieldRecordType *> FieldsContainerType;
//Attempting to avoid VS 6 compiler error typename TNetwork::ConstPointer m_Network;
typename TNetwork::Pointer m_Network;
NetworkWriteWeightsType m_WriteWeightValuesType;
std::string m_FileName;
FieldsContainerType m_Fields;
std::ofstream m_OutputFile;
};
} // namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkNeuralNetworkFileWriter.txx"
#endif
#endif
|