neuralpp/doc/html/neural_09_09_8hpp-source.html

252 lines
37 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Neural++: neural++.hpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>neural++.hpp</h1><a href="neural_09_09_8hpp.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"> * LibNeural++ v.0.2 - All-purpose library for managing neural networks *</span>
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 2009, BlackLight *</span>
<a name="l00004"></a>00004 <span class="comment"> * *</span>
<a name="l00005"></a>00005 <span class="comment"> * This program is free software: you can redistribute it and/or modify it under the terms of the *</span>
<a name="l00006"></a>00006 <span class="comment"> * GNU General Public License as published by the Free Software Foundation, either version 3 of *</span>
<a name="l00007"></a>00007 <span class="comment"> * the License, or (at your option) any later version. This program is distributed in the hope *</span>
<a name="l00008"></a>00008 <span class="comment"> * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of *</span>
<a name="l00009"></a>00009 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *</span>
<a name="l00010"></a>00010 <span class="comment"> * more details. You should have received a copy of the GNU General Public License along with *</span>
<a name="l00011"></a>00011 <span class="comment"> * this program. If not, see &lt;http://www.gnu.org/licenses/&gt;. *</span>
<a name="l00012"></a>00012 <span class="comment"> **************************************************************************************************/</span>
<a name="l00013"></a>00013
<a name="l00014"></a>00014 <span class="comment">//#ifndef __cplusplus</span>
<a name="l00015"></a>00015 <span class="comment">//#error "This is a C++ library, you know, so you'd better use a C++ compiler to compile it"</span>
<a name="l00016"></a>00016 <span class="comment">//#else</span>
<a name="l00017"></a>00017
<a name="l00018"></a>00018 <span class="preprocessor">#ifndef __NEURALPP</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="preprocessor">#define __NEURALPP</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;ctime&gt;</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;cstdio&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="neural_09_09__exception_8hpp.html">neural++_exception.hpp</a>"</span>
<a name="l00029"></a>00029 <span class="keyword">using namespace </span>std;
<a name="l00030"></a>00030
<a name="l00032"></a><a class="code" href="neural_09_09_8hpp.html#839a9222721835f53c5b248241f535f4">00032</a> <span class="preprocessor">#define RAND ( abs( sin(rand()) ) )</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00035"></a><a class="code" href="neural_09_09_8hpp.html#05e2bb5b9fc32f0b6b4d84fe43177d72">00035</a> <span class="preprocessor">#define BETA0 0.7</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="keyword">namespace </span>neuralpp {
<a name="l00042"></a>00042 <span class="keyword">class </span>Synapsis;
<a name="l00043"></a>00043 <span class="keyword">class </span>Neuron;
<a name="l00044"></a>00044 <span class="keyword">class </span>Layer;
<a name="l00045"></a>00045 <span class="keyword">class </span>NeuralNet;
<a name="l00046"></a>00046 <span class="keyword">class </span>NetworkFileNotFoundException;
<a name="l00047"></a>00047 <span class="keyword">class </span>InvalidXMLException;
<a name="l00048"></a>00048
<a name="l00053"></a><a class="code" href="classneuralpp_1_1NeuralNet.html">00053</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1NeuralNet.html" title="Main project&amp;#39;s class.">NeuralNet</a> {
<a name="l00054"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">00054</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">epochs</a>;
<a name="l00055"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">00055</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">ref_epochs</a>;
<a name="l00056"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">00056</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">l_rate</a>;
<a name="l00057"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">00057</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">ex</a>;
<a name="l00058"></a>00058
<a name="l00059"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#e2b4e8405f9d25edab395d61502bdba9">00059</a> <a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a>* <a class="code" href="classneuralpp_1_1NeuralNet.html#e2b4e8405f9d25edab395d61502bdba9">input</a>;
<a name="l00060"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#bbdaa1b6c0a1a95d2b18cd25fda2a266">00060</a> <a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a>* <a class="code" href="classneuralpp_1_1NeuralNet.html#bbdaa1b6c0a1a95d2b18cd25fda2a266">hidden</a>;
<a name="l00061"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#fa9b2dbcbb39d0fc70f790ac24069a74">00061</a> <a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a>* <a class="code" href="classneuralpp_1_1NeuralNet.html#fa9b2dbcbb39d0fc70f790ac24069a74">output</a>;
<a name="l00062"></a>00062
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#94169c89a7cd47122ab5dbf1d5c5e108" title="It updates the weights of the net&amp;#39;s synapsis through back-propagation.">updateWeights</a>();
<a name="l00068"></a>00068
<a name="l00074"></a>00074 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#62695a82dfb1df758a44150921aec8e0" title="It commits the changes made by updateWeights() to the layer l.">commitChanges</a> (<a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a> *l);
<a name="l00075"></a>00075
<a name="l00081"></a>00081 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#8a140d28e6dd4097470c7c138801ad01" title="It get the error made on the expected result as |v-v&amp;#39;|/v.">error</a>(<span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">ex</a>);
<a name="l00082"></a>00082
<a name="l00087"></a>00087 double (*<a class="code" href="classneuralpp_1_1NeuralNet.html#c1469e6afd87d85b82f14bc246f82457" title="Private pointer to function, containing the function to be used as activation function...">actv_f</a>)(double);
<a name="l00088"></a>00088
<a name="l00093"></a>00093 double (*<a class="code" href="classneuralpp_1_1NeuralNet.html#df44689f4e6201ca1ddc67655cce3576" title="Private pointer to function, containing the function to be used as derivate of the...">deriv</a>)(double);
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keyword">public</span>:
<a name="l00099"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">00099</a> <span class="keyword">typedef</span> <span class="keyword">enum</span> { <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f5ec2727c0756ddb097b53efe49b81afb">file</a>, <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">str</a> } <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f" title="Enum to choose the eventual training source for our network (XML from a file or from...">source</a>;
<a name="l00100"></a>00100
<a name="l00104"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2">00104</a> <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a>() {}
<a name="l00105"></a>00105
<a name="l00116"></a>00116 <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a> (<span class="keywordtype">size_t</span> in_size, <span class="keywordtype">size_t</span> hidden_size, <span class="keywordtype">size_t</span> out_size, <span class="keywordtype">double</span> l, <span class="keywordtype">int</span> e);
<a name="l00117"></a>00117
<a name="l00123"></a>00123 <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f5ec2727c0756ddb097b53efe49b81afb">file</a>) <span class="keywordflow">throw</span>(NetworkFileNotFoundException);
<a name="l00124"></a>00124
<a name="l00125"></a>00125
<a name="l00138"></a>00138 <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a> (<span class="keywordtype">size_t</span> in_size, <span class="keywordtype">size_t</span> hidden_size, <span class="keywordtype">size_t</span> out_size,
<a name="l00139"></a>00139 <span class="keywordtype">double</span>(*actv)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*<a class="code" href="classneuralpp_1_1NeuralNet.html#df44689f4e6201ca1ddc67655cce3576" title="Private pointer to function, containing the function to be used as derivate of the...">deriv</a>)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> l, <span class="keywordtype">int</span> e);
<a name="l00140"></a>00140
<a name="l00146"></a>00146 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#7de7ee318eeb791d21a01e9e9e0e8c5a" title="It gets the output of the network (note: the layer output should contain an only...">getOutput</a>();
<a name="l00147"></a>00147
<a name="l00152"></a>00152 vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#a6b8bf3800b43b58843c65fc431207ae" title="It gets the output of the network in case the output layer contains more neurons...">getOutputs</a>();
<a name="l00153"></a>00153
<a name="l00159"></a>00159 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#423fd38a61d79905dcc12da84c805114" title="It gets the value expected.">expected</a>();
<a name="l00160"></a>00160
<a name="l00165"></a>00165 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#b6475762b7e9eab086befdc511f7c236" title="It sets the value you expect from your network.">setExpected</a>(<span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">ex</a>);
<a name="l00166"></a>00166
<a name="l00172"></a>00172 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#b0bd1daadb06980dff1f50d33a7c098e" title="It updates through back-propagation the weights of the synapsis and computes again...">update</a>();
<a name="l00173"></a>00173
<a name="l00178"></a>00178 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#c129c180647362da963758bfd1ba6890" title="It propagates values through the network.">propagate</a>();
<a name="l00179"></a>00179
<a name="l00184"></a>00184 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#0de170e8ab561ad63d0739b4c4b74f68" title="It sets the input for the network.">setInput</a> (vector&lt;double&gt;&amp; v);
<a name="l00185"></a>00185
<a name="l00190"></a>00190 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#46f23f462318a4ffc037a4e806364c3f" title="It links the layers of the network (input, hidden, output).">link</a>();
<a name="l00191"></a>00191
<a name="l00196"></a>00196 <span class="keywordtype">bool</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#5db8d6ba4785f732da6e642b4f8f11a0" title="Save a trained neural network to a binary file.">save</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* fname);
<a name="l00197"></a>00197
<a name="l00205"></a>00205 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#e8b8741d28bec1354db555eabe418cb6" title="Train a network using a training set loaded from an XML file.">train</a>(<span class="keywordtype">string</span> xml, <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f" title="Enum to choose the eventual training source for our network (XML from a file or from...">source</a> xrc) <span class="keywordflow">throw</span>(InvalidXMLException);
<a name="l00206"></a>00206
<a name="l00211"></a>00211 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#45c7645d4affe65752d37cd230afba24" title="Initialize the training XML for the neural network.">initXML</a> (<span class="keywordtype">string</span>&amp; xml);
<a name="l00212"></a>00212
<a name="l00219"></a>00219 <span class="keyword">static</span> vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#e07af23ceb8666518da0c035bf1e0376" title="Splits a string into a vector of doubles, given a delimitator.">split</a> (<span class="keywordtype">char</span> delim, <span class="keywordtype">string</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">str</a>);
<a name="l00220"></a>00220
<a name="l00233"></a>00233 <span class="keyword">static</span> <span class="keywordtype">string</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4be31ecb0b543a192997bd83c6995ccb" title="Get a training set from a string and copies it to an XML For example, these strings...">XMLFromSet</a> (<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keywordtype">string</span> <span class="keyword">set</span>);
<a name="l00234"></a>00234
<a name="l00239"></a>00239 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#28b9966c5f197b8e86d57dd104aa32a6" title="Closes an open XML document generated by &amp;quot;initXML&amp;quot; and &amp;quot;XMLFromSet&amp;quot;...">closeXML</a>(<span class="keywordtype">string</span>&amp; xml);
<a name="l00240"></a>00240 };
<a name="l00241"></a>00241
<a name="l00247"></a><a class="code" href="classneuralpp_1_1Synapsis.html">00247</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a> {
<a name="l00248"></a><a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">00248</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">delta</a>;
<a name="l00249"></a><a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">00249</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">prev_delta</a>;
<a name="l00250"></a><a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">00250</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">weight</a>;
<a name="l00251"></a>00251
<a name="l00252"></a><a class="code" href="classneuralpp_1_1Synapsis.html#83d41c158054b08bd05051736e89a0ad">00252</a> <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> *<a class="code" href="classneuralpp_1_1Synapsis.html#83d41c158054b08bd05051736e89a0ad">in</a>;
<a name="l00253"></a><a class="code" href="classneuralpp_1_1Synapsis.html#fb219e05038fa0da20db1082ab0500be">00253</a> <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> *<a class="code" href="classneuralpp_1_1Synapsis.html#fb219e05038fa0da20db1082ab0500be">out</a>;
<a name="l00254"></a>00254
<a name="l00255"></a>00255 double (*<a class="code" href="classneuralpp_1_1Synapsis.html#2539b9eef2ff0f3522aea8d89e394f02">actv_f</a>)(double);
<a name="l00256"></a>00256 double (*<a class="code" href="classneuralpp_1_1Synapsis.html#2940b370c283aa1b63890666942c26bf">deriv</a>)(double);
<a name="l00257"></a>00257
<a name="l00258"></a>00258 <span class="keyword">public</span>:
<a name="l00266"></a>00266 <a class="code" href="classneuralpp_1_1Synapsis.html#0729de9e737b9967421edcfc4b410bd8" title="Constructor.">Synapsis</a>(<a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* i, <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* o, <span class="keywordtype">double</span> w, <span class="keywordtype">double</span> d);
<a name="l00267"></a>00267
<a name="l00275"></a>00275 <a class="code" href="classneuralpp_1_1Synapsis.html#0729de9e737b9967421edcfc4b410bd8" title="Constructor.">Synapsis</a> (<a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* i, <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* o, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00276"></a>00276
<a name="l00285"></a>00285 <a class="code" href="classneuralpp_1_1Synapsis.html#0729de9e737b9967421edcfc4b410bd8" title="Constructor.">Synapsis</a> (<a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* i, <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* o,
<a name="l00286"></a>00286 <span class="keywordtype">double</span> w, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00287"></a>00287
<a name="l00291"></a>00291 <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* <a class="code" href="classneuralpp_1_1Synapsis.html#5ba8a93a5741f4855390eb8a46e99435">getIn</a>();
<a name="l00292"></a>00292
<a name="l00296"></a>00296 <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* <a class="code" href="classneuralpp_1_1Synapsis.html#61c9a04e03291a01f44520cef143cbdd">getOut</a>();
<a name="l00297"></a>00297
<a name="l00302"></a>00302 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Synapsis.html#acee77d0fdf9889464ab5ed27beae0ff" title="Set the weight of the synapsis.">setWeight</a>(<span class="keywordtype">double</span> w);
<a name="l00303"></a>00303
<a name="l00309"></a>00309 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Synapsis.html#429ad5b25930faf436a9d725582802e1" title="It sets the delta (how much to change the weight after an update) of the synapsis...">setDelta</a>(<span class="keywordtype">double</span> d);
<a name="l00310"></a>00310
<a name="l00315"></a>00315 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#aa79c16ec6b59949e5d2f75a3f10d530" title="Return the weight of the synapsis.">getWeight</a>();
<a name="l00316"></a>00316
<a name="l00321"></a>00321 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#18f15b920609be8b818d43a0227aada5" title="Return the delta of the synapsis.">getDelta</a>();
<a name="l00322"></a>00322
<a name="l00327"></a>00327 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#2fe3e9ec97542f1476d8b9306aa09756" title="Get the delta of the synapsis at the previous iteration.">getPrevDelta</a>();
<a name="l00328"></a>00328
<a name="l00339"></a>00339 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#ecdb17182de791f7fdd417232e184350" title="Get the inertial momentum of a synapsis.">momentum</a> (<span class="keywordtype">int</span> N, <span class="keywordtype">int</span> x);
<a name="l00340"></a>00340 };
<a name="l00341"></a>00341
<a name="l00347"></a><a class="code" href="classneuralpp_1_1Neuron.html">00347</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> {
<a name="l00348"></a><a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">00348</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">actv_val</a>;
<a name="l00349"></a><a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">00349</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">prop_val</a>;
<a name="l00350"></a>00350
<a name="l00351"></a><a class="code" href="classneuralpp_1_1Neuron.html#ead827210fa18c2baae03927b2c798ff">00351</a> vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#ead827210fa18c2baae03927b2c798ff">in</a>;
<a name="l00352"></a><a class="code" href="classneuralpp_1_1Neuron.html#82a4297f84d6403e52a8386d26117b4f">00352</a> vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#82a4297f84d6403e52a8386d26117b4f">out</a>;
<a name="l00353"></a>00353
<a name="l00354"></a>00354 double (*<a class="code" href="classneuralpp_1_1Neuron.html#198ddd0d11a26d0052d52b787d6a0df0">actv_f</a>)(double);
<a name="l00355"></a>00355 double (*<a class="code" href="classneuralpp_1_1Neuron.html#8b881889e40e9782c49b0efad2b1dde3">deriv</a>)(double);
<a name="l00356"></a>00356 <span class="keyword">public</span>:
<a name="l00362"></a>00362 <a class="code" href="classneuralpp_1_1Neuron.html#c877424a295478e3464046ea43c2a7ad" title="Constructor.">Neuron</a> (<span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00363"></a>00363
<a name="l00371"></a>00371 <a class="code" href="classneuralpp_1_1Neuron.html#c877424a295478e3464046ea43c2a7ad" title="Constructor.">Neuron</a> (vector&lt;Synapsis&gt; <a class="code" href="classneuralpp_1_1Neuron.html#ead827210fa18c2baae03927b2c798ff">in</a>, vector&lt;Synapsis&gt; <a class="code" href="classneuralpp_1_1Neuron.html#82a4297f84d6403e52a8386d26117b4f">out</a>,
<a name="l00372"></a>00372 <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00373"></a>00373
<a name="l00379"></a>00379 <a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a>&amp; <a class="code" href="classneuralpp_1_1Neuron.html#29f2d9dcc4ca34f224d4dc39bb2f180a" title="Get the i-th synapsis connected on the input of the neuron.">synIn</a> (<span class="keywordtype">size_t</span> i);
<a name="l00380"></a>00380
<a name="l00386"></a>00386 <a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a>&amp; <a class="code" href="classneuralpp_1_1Neuron.html#655f1637e1b754461413ac7fc2ffeebe" title="Get the i-th synapsis connected on the output of the neuron.">synOut</a> (<span class="keywordtype">size_t</span> i);
<a name="l00387"></a>00387
<a name="l00392"></a>00392 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#583ada6e1dd3f2e113415b4d89196e62" title="It pushes a new input synapsis.">push_in</a> (<a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a>&amp; s);
<a name="l00393"></a>00393
<a name="l00398"></a>00398 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#bca65db84f56f9d40694bfbcd25812cb" title="It pushes a new output synapsis.">push_out</a> (<a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a>&amp; s);
<a name="l00399"></a>00399
<a name="l00404"></a>00404 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#ddf00ffef030b27ed11901aad08822bd" title="Change the activation value of the neuron.">setActv</a> (<span class="keywordtype">double</span> a);
<a name="l00405"></a>00405
<a name="l00410"></a>00410 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#aa6e58f073a76b3481fea9115a4e6ea6" title="Change the propagation value of the neuron.">setProp</a> (<span class="keywordtype">double</span> p);
<a name="l00411"></a>00411
<a name="l00416"></a>00416 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#55993867179f0ac7d1e0e2c460ceb611" title="Get the activation value of the neuron.">getActv</a>();
<a name="l00417"></a>00417
<a name="l00422"></a>00422 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#57c022f82213f662e2a263fc134a3fc9" title="Get the propagation value of the neuron.">getProp</a>();
<a name="l00423"></a>00423
<a name="l00427"></a>00427 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#8b0ca61cd0e047c8691ab39aae56dbda" title="It propagates its activation value to the connected neurons.">propagate</a>();
<a name="l00428"></a>00428
<a name="l00433"></a>00433 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Neuron.html#ad97f1a082d5f969eb4c69ab454ecfbb" title="Get the number of input synapsis for the neuron.">nIn</a>();
<a name="l00434"></a>00434
<a name="l00439"></a>00439 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Neuron.html#fe458021e3b20d58dc608fb94ae2135b" title="Get the number of output synapsis for the neuron.">nOut</a>();
<a name="l00440"></a>00440
<a name="l00444"></a>00444 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#2e2ccb69277fc3d992a3a3f2360ed154" title="Remove input and output synapsis from a neuron.">synClear</a>();
<a name="l00445"></a>00445 };
<a name="l00446"></a>00446
<a name="l00452"></a><a class="code" href="classneuralpp_1_1Layer.html">00452</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a> {
<a name="l00453"></a><a class="code" href="classneuralpp_1_1Layer.html#855685c9da56b06b629e13a2f8c719ce">00453</a> vector&lt;Neuron&gt; <a class="code" href="classneuralpp_1_1Layer.html#855685c9da56b06b629e13a2f8c719ce">elements</a>;
<a name="l00454"></a>00454
<a name="l00455"></a>00455 void (*<a class="code" href="classneuralpp_1_1Layer.html#c023a15a16353d0b4f44060a159f550f">update_weights</a>)();
<a name="l00456"></a>00456 double (*<a class="code" href="classneuralpp_1_1Layer.html#824367da29f92253a027a7c5b4a4405e">actv_f</a>)(double);
<a name="l00457"></a>00457 double (*<a class="code" href="classneuralpp_1_1Layer.html#a0207b14ba80aaf03502749ecb7d23fa">deriv</a>)(double);
<a name="l00458"></a>00458
<a name="l00459"></a>00459 <span class="keyword">public</span>:
<a name="l00466"></a>00466 <a class="code" href="classneuralpp_1_1Layer.html#411a4dc8a1bb2fe44fe7a69fa50fd764" title="Constructor.">Layer</a> (<span class="keywordtype">size_t</span> sz, <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00467"></a>00467
<a name="l00475"></a>00475 <a class="code" href="classneuralpp_1_1Layer.html#411a4dc8a1bb2fe44fe7a69fa50fd764" title="Constructor.">Layer</a> (vector&lt;Neuron&gt;&amp; neurons, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span>(*d)(<span class="keywordtype">double</span>));
<a name="l00476"></a>00476
<a name="l00482"></a>00482 <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>&amp; <a class="code" href="classneuralpp_1_1Layer.html#45ff7554830558155c6fbce3b6827122" title="Redefinition for operator [].">operator[] </a>(<span class="keywordtype">size_t</span> i);
<a name="l00483"></a>00483
<a name="l00488"></a>00488 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Layer.html#ac33444fde14633fa1ad4acb024ad150" title="It links a layer to another.">link</a> (<a class="code" href="classneuralpp_1_1Layer.html" title="Class for managing layers of neurons.">Layer</a>&amp; l);
<a name="l00489"></a>00489
<a name="l00494"></a>00494 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Layer.html#dbad95f635343a2998794113d7762cf7" title="It sets a vector of propagation values to all its neurons.">setProp</a> (vector&lt;double&gt;&amp; v);
<a name="l00495"></a>00495
<a name="l00500"></a>00500 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Layer.html#98f79281b680b1d18fd91fa5794c0899" title="It sets a vector of activation values to all its neurons.">setActv</a> (vector&lt;double&gt;&amp; v);
<a name="l00501"></a>00501
<a name="l00505"></a>00505 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Layer.html#fcfd306039dbaf91c9e2dcc8fc1f1ce1" title="It propagates its activation values to the output layers.">propagate</a>();
<a name="l00506"></a>00506
<a name="l00510"></a>00510 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Layer.html#c8d2f7513e5d40518f9dddfd1e3ddcc5">size</a>();
<a name="l00511"></a>00511 };
<a name="l00512"></a>00512
<a name="l00513"></a><a class="code" href="structneuralpp_1_1netrecord.html">00513</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1netrecord.html">netrecord</a> {
<a name="l00514"></a><a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">00514</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">input_size</a>;
<a name="l00515"></a><a class="code" href="structneuralpp_1_1netrecord.html#3c1728ac66c37f6ac85c404d4f55552e">00515</a> <span class="keywordtype">int</span> hidden_size;
<a name="l00516"></a><a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">00516</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">output_size</a>;
<a name="l00517"></a>00517
<a name="l00518"></a><a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">00518</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">epochs</a>;
<a name="l00519"></a><a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">00519</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">l_rate</a>;
<a name="l00520"></a><a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">00520</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">ex</a>;
<a name="l00521"></a>00521 };
<a name="l00522"></a>00522
<a name="l00523"></a><a class="code" href="structneuralpp_1_1neuronrecord.html">00523</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1neuronrecord.html">neuronrecord</a> {
<a name="l00524"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">00524</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">prop</a>;
<a name="l00525"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">00525</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">actv</a>;
<a name="l00526"></a>00526 };
<a name="l00527"></a>00527
<a name="l00528"></a><a class="code" href="structneuralpp_1_1synrecord.html">00528</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1synrecord.html">synrecord</a> {
<a name="l00529"></a><a class="code" href="structneuralpp_1_1synrecord.html#81a7dbc97eecbf5bc85cac46373a78d2">00529</a> <span class="keywordtype">double</span> w;
<a name="l00530"></a><a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">00530</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">d</a>;
<a name="l00531"></a>00531 };
<a name="l00532"></a>00532 }
<a name="l00533"></a>00533
<a name="l00534"></a>00534 <span class="preprocessor">#endif</span>
<a name="l00535"></a>00535 <span class="preprocessor"></span><span class="comment">//#endif</span>
<a name="l00536"></a>00536
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 9 11:11:18 2009 for Neural++ by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>