<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><meta name="robots" content="noindex"> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>ITK: itkTrainingFunctionBase.h Source File</title> <link href="DoxygenStyle.css" rel="stylesheet" type="text/css"> </head><body bgcolor="#ffffff"> <!-- Section customized for INSIGHT : Tue Jul 17 01:02:45 2001 --> <center> <a href="index.html" class="qindex">Main Page</a> <a href="modules.html" class="qindex">Groups</a> <a href="namespaces.html" class="qindex">Namespace List</a> <a href="hierarchy.html" class="qindex">Class Hierarchy</a> <a href="classes.html" class="qindex">Alphabetical List</a> <a href="annotated.html" class="qindex">Compound List</a> <a href="files.html" class="qindex">File List</a> <a href="namespacemembers.html" class="qindex">Namespace Members</a> <a href="functions.html" class="qindex">Compound Members</a> <a href="globals.html" class="qindex">File Members</a> <a href="pages.html" class="qindex">Concepts</a></center> <!-- Generated by Doxygen 1.5.9 --> <div class="navpath"><a class="el" href="dir_02e23d841c198393a6e961e9a0678fff.html">Code</a> » <a class="el" href="dir_2c33022d19e8077162952ea9ed57656d.html">Numerics</a> » <a class="el" href="dir_eec394370736d51e5081e791ec403a83.html">NeuralNetworks</a> </div> <div class="contents"> <h1>itkTrainingFunctionBase.h</h1><a href="itkTrainingFunctionBase_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*=========================================================================</span> <a name="l00002"></a>00002 <span class="comment"></span> <a name="l00003"></a>00003 <span class="comment"> Program: Insight Segmentation & Registration Toolkit</span> <a name="l00004"></a>00004 <span class="comment"> Module: $RCSfile: itkTrainingFunctionBase.h,v $</span> <a name="l00005"></a>00005 <span class="comment"> Language: C++</span> <a name="l00006"></a>00006 <span class="comment"> Date: $Date: 2009-01-28 21:04:59 $</span> <a name="l00007"></a>00007 <span class="comment"> Version: $Revision: 1.8 $</span> <a name="l00008"></a>00008 <span class="comment"></span> <a name="l00009"></a>00009 <span class="comment"> Copyright (c) Insight Software Consortium. All rights reserved.</span> <a name="l00010"></a>00010 <span class="comment"> See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.</span> <a name="l00011"></a>00011 <span class="comment"></span> <a name="l00012"></a>00012 <span class="comment"> This software is distributed WITHOUT ANY WARRANTY; without even </span> <a name="l00013"></a>00013 <span class="comment"> the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR </span> <a name="l00014"></a>00014 <span class="comment"> PURPOSE. See the above copyright notices for more information.</span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment">=========================================================================*/</span> <a name="l00017"></a>00017 <a name="l00018"></a>00018 <span class="preprocessor">#ifndef __itkTrainingFunctionBase_h</span> <a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define __itkTrainingFunctionBase_h</span> <a name="l00020"></a>00020 <span class="preprocessor"></span> <a name="l00021"></a>00021 <span class="preprocessor">#include <iostream></span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="itkLightProcessObject_8h.html">itkLightProcessObject.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="itkNeuralNetworkObject_8h.html">itkNeuralNetworkObject.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="itkSquaredDifferenceErrorFunction_8h.html">itkSquaredDifferenceErrorFunction.h</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="itkMeanSquaredErrorFunction_8h.html">itkMeanSquaredErrorFunction.h</a>"</span> <a name="l00026"></a>00026 <span class="keyword">namespace </span>itk <a name="l00027"></a>00027 { <a name="l00028"></a>00028 <span class="keyword">namespace </span>Statistics <a name="l00029"></a>00029 { <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">template</span><<span class="keyword">class</span> TSample, <span class="keyword">class</span> TTargetVector, <span class="keyword">class</span> ScalarType> <a name="l00032"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html">00032</a> <span class="keyword">class </span><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html">TrainingFunctionBase</a> : <span class="keyword">public</span> <a class="code" href="classitk_1_1LightProcessObject.html" title="LightProcessObject is the base class for all process objects (source, filters, mappers)...">LightProcessObject</a> <a name="l00033"></a>00033 { <a name="l00034"></a>00034 <span class="keyword">public</span>: <a name="l00035"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#c34357e2252d02d4bb82f666b1a3ddc4">00035</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html">TrainingFunctionBase</a> <a class="code" href="classitk_1_1LightObject.html" title="Light weight base class for most itk classes.">Self</a>; <a name="l00036"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#deb1e41d0950e3449d2182445ca08fbf">00036</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1LightProcessObject.html" title="LightProcessObject is the base class for all process objects (source, filters, mappers)...">LightProcessObject</a> <a class="code" href="classitk_1_1Object.html" title="Base class for most itk classes.">Superclass</a>; <a name="l00037"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#8786a041c00711b192aee32bfae6012d">00037</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1SmartPointer.html">SmartPointer<Self></a> <a class="code" href="classitk_1_1SmartPointer.html">Pointer</a>; <a name="l00038"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#705a74d1771db2a2af29f522170bd1e0">00038</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1SmartPointer.html">SmartPointer<const Self></a> <a class="code" href="classitk_1_1SmartPointer.html">ConstPointer</a>; <a name="l00039"></a>00039 <a name="l00041"></a>00041 <a class="code" href="itkMacro_8h.html#574c1f86661d409dd32c742307a0e96a">itkTypeMacro</a>(<a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html">TrainingFunctionBase</a>, <a class="code" href="classitk_1_1LightProcessObject.html" title="LightProcessObject is the base class for all process objects (source, filters, mappers)...">LightProcessObject</a>); <a name="l00042"></a>00042 <a name="l00044"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f0ced2719a03a4fdef720ebc605b8a">00044</a> <a class="code" href="itkMacro_8h.html#0fdc15685afa271857c57e7cd482f30c">itkNewMacro</a>(<a class="code" href="classitk_1_1LightObject.html" title="Light weight base class for most itk classes.">Self</a>); <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">typedef</span> ScalarType <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f0ced2719a03a4fdef720ebc605b8a">ValueType</a>; <a name="l00047"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#0f98eafb6bd2b5de65cab6ae2a567465">00047</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> TSample::MeasurementVectorType <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#0f98eafb6bd2b5de65cab6ae2a567465">VectorType</a>; <a name="l00048"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#00880a7b7b25deb0fa64f4a201ae5b95">00048</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> TTargetVector::MeasurementVectorType <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#00880a7b7b25deb0fa64f4a201ae5b95">OutputVectorType</a>; <a name="l00049"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#578f31dec4b605af8ef7f3258da2941c">00049</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Array.html" title="Array class with size defined at construction time.">Array<ValueType></a> <a class="code" href="classitk_1_1Array.html" title="Array class with size defined at construction time.">InternalVectorType</a>; <a name="l00050"></a>00050 <a name="l00051"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#798f9e1695e135035141a70e21b4aa06">00051</a> <span class="keyword">typedef</span> std::vector<VectorType> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#798f9e1695e135035141a70e21b4aa06">InputSampleVectorType</a>; <a name="l00052"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e25b71010499770445e58843a481a063">00052</a> <span class="keyword">typedef</span> std::vector<OutputVectorType> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e25b71010499770445e58843a481a063">OutputSampleVectorType</a>; <a name="l00053"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f52a3aafc41b3b8fee92c139507df3">00053</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Statistics_1_1NeuralNetworkObject.html">NeuralNetworkObject<VectorType, OutputVectorType></a> <a class="code" href="classitk_1_1Statistics_1_1NeuralNetworkObject.html">NetworkType</a>; <a name="l00054"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#3eb05fce0657d19cf3f92053b5e68a2c">00054</a> <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Statistics_1_1ErrorFunctionBase.html">ErrorFunctionBase<InternalVectorType, ScalarType></a> <a class="code" href="classitk_1_1Statistics_1_1ErrorFunctionBase.html">PerformanceFunctionType</a>; <a name="l00055"></a>00055 <span class="keyword">typedef</span> <a class="code" href="classitk_1_1Statistics_1_1SquaredDifferenceErrorFunction.html">SquaredDifferenceErrorFunction<InternalVectorType, ScalarType></a> <a name="l00056"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#af3a426732e182a73f1c75c684618512">00056</a> <a class="code" href="classitk_1_1Statistics_1_1SquaredDifferenceErrorFunction.html">DefaultPerformanceType</a>; <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#656e344a49380da8b94fb057bf05da15">SetTrainingSamples</a>(TSample* samples); <a name="l00059"></a>00059 <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#36be8aab338f0b87de171cb88b338d51">SetTargetValues</a>(TTargetVector* targets); <a name="l00060"></a>00060 <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#d7ea621f9babeb9a0181cd70f67a7ef7">SetLearningRate</a>(<a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f0ced2719a03a4fdef720ebc605b8a">ValueType</a>); <a name="l00061"></a>00061 <a name="l00062"></a>00062 <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f0ced2719a03a4fdef720ebc605b8a">ValueType</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#6b35ca05e5865a571b827b587391f98d">GetLearningRate</a>(); <a name="l00063"></a>00063 <a name="l00064"></a>00064 <a class="code" href="itkMacro_8h.html#7ebdd33cc5e7d74720ced9099c034faa">itkSetMacro</a>(Iterations, <span class="keywordtype">long</span>); <a name="l00065"></a>00065 <a class="code" href="itkMacro_8h.html#7d989c13a1a213168db99ae0f84185d4">itkGetConstReferenceMacro</a>(Iterations, <span class="keywordtype">long</span>); <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#d185709de6ea83f7789c29f58af25170">SetPerformanceFunction</a>(<a class="code" href="classitk_1_1Statistics_1_1ErrorFunctionBase.html">PerformanceFunctionType</a>* f); <a name="l00068"></a>00068 <a name="l00069"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e7b37b1fabe972bfb9896357892bbddb">00069</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e7b37b1fabe972bfb9896357892bbddb">Train</a>(<a class="code" href="classitk_1_1Statistics_1_1NeuralNetworkObject.html">NetworkType</a>* <a class="code" href="itkMacro_8h.html#6be3b439282da7a34278c0594589b972">itkNotUsed</a>(net), TSample* <a class="code" href="itkMacro_8h.html#6be3b439282da7a34278c0594589b972">itkNotUsed</a>(samples), TTargetVector* <a class="code" href="itkMacro_8h.html#6be3b439282da7a34278c0594589b972">itkNotUsed</a>(targets)) <a name="l00070"></a>00070 { <a name="l00071"></a>00071 <span class="comment">// not implemented</span> <a name="l00072"></a>00072 }; <a name="l00073"></a>00073 <a name="l00074"></a>00074 <span class="keyword">inline</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#0f98eafb6bd2b5de65cab6ae2a567465">VectorType</a> <a name="l00075"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#79f1cb57fcbef981a12d1066a2b08dc4">00075</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#79f1cb57fcbef981a12d1066a2b08dc4">defaultconverter</a>(<span class="keyword">typename</span> TSample::MeasurementVectorType v) <a name="l00076"></a>00076 { <a name="l00077"></a>00077 <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#0f98eafb6bd2b5de65cab6ae2a567465">VectorType</a> temp; <a name="l00078"></a>00078 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < v.Size(); i++) <a name="l00079"></a>00079 { <a name="l00080"></a>00080 temp[i] = <span class="keyword">static_cast<</span>ScalarType<span class="keyword">></span>(v[i]); <a name="l00081"></a>00081 } <a name="l00082"></a>00082 <span class="keywordflow">return</span> temp; <a name="l00083"></a>00083 } <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keyword">inline</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#00880a7b7b25deb0fa64f4a201ae5b95">OutputVectorType</a> <a name="l00086"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#4b690fb7d209922172e1ebf1fff3b65b">00086</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#4b690fb7d209922172e1ebf1fff3b65b">targetconverter</a>(<span class="keyword">typename</span> TTargetVector::MeasurementVectorType v) <a name="l00087"></a>00087 { <a name="l00088"></a>00088 <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#00880a7b7b25deb0fa64f4a201ae5b95">OutputVectorType</a> temp; <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0; i < v.Size(); i++) <a name="l00091"></a>00091 { <a name="l00092"></a>00092 temp[i] = <span class="keyword">static_cast<</span>ScalarType<span class="keyword">></span>(v[i]); <a name="l00093"></a>00093 } <a name="l00094"></a>00094 <span class="keywordflow">return</span> temp; <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="keyword">protected</span>: <a name="l00098"></a>00098 <a name="l00099"></a>00099 <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#dbae8125843878edb78cfcd0bb3d5f1e">TrainingFunctionBase</a>(); <a name="l00100"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#55087104a15615ff6559295f25c5c74c">00100</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#55087104a15615ff6559295f25c5c74c">~TrainingFunctionBase</a>(){}; <a name="l00101"></a>00101 <a name="l00103"></a>00103 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e0f5d35090c602b6da7d54ee7ed6cf25">PrintSelf</a>( std::ostream& os, <a class="code" href="classitk_1_1Indent.html" title="Control indentation during Print() invocation.">Indent</a> indent ) <span class="keyword">const</span>; <a name="l00104"></a>00104 <a name="l00105"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#ac714950f89a2e61240bd30e392e5d8d">00105</a> TSample* <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#ac714950f89a2e61240bd30e392e5d8d">m_TrainingSamples</a>;<span class="comment">// original samples</span> <a name="l00106"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#6d17c9f8e259716716371e6788575a9c">00106</a> TTargetVector* <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#6d17c9f8e259716716371e6788575a9c">m_SampleTargets</a>; <span class="comment">// original samples</span> <a name="l00107"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#4fb6070984348abc418fe2c694676928">00107</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#798f9e1695e135035141a70e21b4aa06">InputSampleVectorType</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#4fb6070984348abc418fe2c694676928">m_InputSamples</a>; <span class="comment">// itk::vectors</span> <a name="l00108"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#2a39d0b8efff9a063267a23aa32d754d">00108</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#e25b71010499770445e58843a481a063">OutputSampleVectorType</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#2a39d0b8efff9a063267a23aa32d754d">m_Targets</a>; <span class="comment">// itk::vectors</span> <a name="l00109"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#a58778bdd1bc3a6ad43ee44f8dac57bc">00109</a> <span class="keywordtype">long</span> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#a58778bdd1bc3a6ad43ee44f8dac57bc">m_Iterations</a>; <a name="l00110"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#ec92a13c10880c9b3d8187482f24fd03">00110</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#06f0ced2719a03a4fdef720ebc605b8a">ValueType</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#ec92a13c10880c9b3d8187482f24fd03">m_LearningRate</a>; <a name="l00111"></a>00111 <a name="l00112"></a><a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#af2efcfed59d5830bbeb2a940f39b1db">00112</a> <span class="keyword">typename</span> <a class="code" href="classitk_1_1SmartPointer.html">PerformanceFunctionType::Pointer</a> <a class="code" href="classitk_1_1Statistics_1_1TrainingFunctionBase.html#af2efcfed59d5830bbeb2a940f39b1db">m_PerformanceFunction</a>; <a name="l00113"></a>00113 }; <a name="l00114"></a>00114 <a name="l00115"></a>00115 } <span class="comment">// end namespace Statistics</span> <a name="l00116"></a>00116 } <span class="comment">// end namespace itk</span> <a name="l00117"></a>00117 <span class="preprocessor">#ifndef ITK_MANUAL_INSTANTIATION</span> <a name="l00118"></a>00118 <span class="preprocessor"></span><span class="preprocessor">#include "itkTrainingFunctionBase.txx"</span> <a name="l00119"></a>00119 <span class="preprocessor">#endif</span> <a name="l00120"></a>00120 <span class="preprocessor"></span> <a name="l00121"></a>00121 <span class="preprocessor">#endif</span> <a name="l00122"></a>00122 <span class="preprocessor"></span> </pre></div></div> <hr><address><small> Generated at Fri May 8 00:23:03 2009 for ITK by <a href="http://www.stack.nl/~dimitri/doxygen/index.html"> <img src="http://www.stack.nl/~dimitri/doxygen/doxygen.png" alt="doxygen" align="middle" border=0 width=110 height=53> </a> 1.5.9 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>, © 1997-2000</small></address> </body> </html>