neuralpp/doc/html/neural_09_09_8hpp-source.html

245 lines
36 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 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00024"></a>00024
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="neural_09_09__exception_8hpp.html">neural++_exception.hpp</a>"</span>
<a name="l00026"></a>00026 <span class="keyword">using namespace </span>std;
<a name="l00027"></a>00027
<a name="l00029"></a><a class="code" href="neural_09_09_8hpp.html#839a9222721835f53c5b248241f535f4">00029</a> <span class="preprocessor">#define RAND (double) ( (rand() / (RAND_MAX/2)) - 1)</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00032"></a><a class="code" href="neural_09_09_8hpp.html#05e2bb5b9fc32f0b6b4d84fe43177d72">00032</a> <span class="preprocessor">#define BETA0 0.8</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="keyword">namespace </span>neuralpp {
<a name="l00039"></a>00039 <span class="keyword">class </span>Synapsis;
<a name="l00040"></a>00040 <span class="keyword">class </span>Neuron;
<a name="l00041"></a>00041 <span class="keyword">class </span>Layer;
<a name="l00042"></a>00042 <span class="keyword">class </span>NeuralNet;
<a name="l00043"></a>00043
<a name="l00044"></a>00044 <span class="keywordtype">double</span> <a class="code" href="namespaceneuralpp.html#43c8197cc83f65fa9676386579671aec">df</a> (<span class="keywordtype">double</span> (*f)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> x);
<a name="l00045"></a>00045
<a name="l00050"></a><a class="code" href="classneuralpp_1_1NeuralNet.html">00050</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="l00051"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">00051</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">epochs</a>;
<a name="l00052"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">00052</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">ref_epochs</a>;
<a name="l00053"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">00053</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">l_rate</a>;
<a name="l00054"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">00054</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#261f5f68fcc5be54250cfa03945266dd">ex</a>;
<a name="l00055"></a>00055
<a name="l00060"></a>00060 <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="l00061"></a>00061
<a name="l00067"></a>00067 <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="l00068"></a>00068
<a name="l00074"></a>00074 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#0616c51404efaca2714e37dd7478997e" title="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>) <span class="keyword">const</span>;
<a name="l00075"></a>00075
<a name="l00080"></a>00080 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="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keyword">public</span>:
<a name="l00083"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#e2b4e8405f9d25edab395d61502bdba9">00083</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="l00084"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#bbdaa1b6c0a1a95d2b18cd25fda2a266">00084</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="l00085"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#fa9b2dbcbb39d0fc70f790ac24069a74">00085</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="l00086"></a>00086
<a name="l00090"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">00090</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="l00091"></a>00091
<a name="l00095"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2">00095</a> <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a>() {}
<a name="l00096"></a>00096
<a name="l00107"></a>00107 <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="l00108"></a>00108
<a name="l00114"></a>00114 <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">string</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f5ec2727c0756ddb097b53efe49b81afb">file</a>) <span class="keywordflow">throw</span>(NetworkFileNotFoundException);
<a name="l00115"></a>00115
<a name="l00116"></a>00116
<a name="l00128"></a>00128 <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="l00129"></a>00129 <span class="keywordtype">double</span>(*actv)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> l, <span class="keywordtype">int</span> e);
<a name="l00130"></a>00130
<a name="l00136"></a>00136 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#961dce8913264bf64c899dce4e25f810" title="It gets the output of the network (note: the layer output should contain an only...">getOutput</a>() <span class="keyword">const</span>;
<a name="l00137"></a>00137
<a name="l00142"></a>00142 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="l00143"></a>00143
<a name="l00149"></a>00149 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#562dfe9fb8d73bf25a23ce608451d3aa" title="It gets the value expected.">expected</a>() <span class="keyword">const</span>;
<a name="l00150"></a>00150
<a name="l00155"></a>00155 <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="l00156"></a>00156
<a name="l00162"></a>00162 <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="l00163"></a>00163
<a name="l00168"></a>00168 <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="l00169"></a>00169
<a name="l00174"></a>00174 <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="l00175"></a>00175
<a name="l00180"></a>00180 <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="l00181"></a>00181
<a name="l00188"></a>00188 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#fdf94c276720c25e565cac834fe8a407" title="Save a trained neural network to a binary file.">save</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* fname) <span class="keywordflow">throw</span>(NetworkFileWriteException);
<a name="l00189"></a>00189
<a name="l00197"></a>00197 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#ead4bdef0602a5cadbe3beb685e01f5f" 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> src) <span class="keywordflow">throw</span>(InvalidXMLException);
<a name="l00198"></a>00198
<a name="l00203"></a>00203 <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="l00204"></a>00204
<a name="l00211"></a>00211 <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="l00212"></a>00212
<a name="l00225"></a>00225 <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="l00226"></a>00226
<a name="l00231"></a>00231 <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="l00232"></a>00232 };
<a name="l00233"></a>00233
<a name="l00239"></a><a class="code" href="classneuralpp_1_1Synapsis.html">00239</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a> {
<a name="l00240"></a><a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">00240</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">delta</a>;
<a name="l00241"></a><a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">00241</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">prev_delta</a>;
<a name="l00242"></a><a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">00242</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">weight</a>;
<a name="l00243"></a>00243
<a name="l00244"></a><a class="code" href="classneuralpp_1_1Synapsis.html#83d41c158054b08bd05051736e89a0ad">00244</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="l00245"></a><a class="code" href="classneuralpp_1_1Synapsis.html#fb219e05038fa0da20db1082ab0500be">00245</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="l00246"></a>00246
<a name="l00247"></a>00247 double (*<a class="code" href="classneuralpp_1_1Synapsis.html#2539b9eef2ff0f3522aea8d89e394f02">actv_f</a>)(double);
<a name="l00248"></a>00248
<a name="l00249"></a>00249 <span class="keyword">public</span>:
<a name="l00257"></a>00257 <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="l00258"></a>00258
<a name="l00265"></a>00265 <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>));
<a name="l00266"></a>00266
<a name="l00274"></a>00274 <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="l00275"></a>00275 <span class="keywordtype">double</span> w, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>));
<a name="l00276"></a>00276
<a name="l00280"></a>00280 <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="l00281"></a>00281
<a name="l00285"></a>00285 <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="l00286"></a>00286
<a name="l00291"></a>00291 <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) <span class="keywordflow">throw</span>(InvalidSynapticalWeightException);
<a name="l00292"></a>00292
<a name="l00298"></a>00298 <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) <span class="keywordflow">throw</span>(InvalidSynapticalWeightException);
<a name="l00299"></a>00299
<a name="l00304"></a>00304 <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="l00305"></a>00305
<a name="l00310"></a>00310 <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="l00311"></a>00311
<a name="l00316"></a>00316 <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="l00317"></a>00317
<a name="l00328"></a>00328 <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="l00329"></a>00329 };
<a name="l00330"></a>00330
<a name="l00336"></a><a class="code" href="classneuralpp_1_1Neuron.html">00336</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> {
<a name="l00337"></a><a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">00337</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">actv_val</a>;
<a name="l00338"></a><a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">00338</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">prop_val</a>;
<a name="l00339"></a>00339
<a name="l00340"></a><a class="code" href="classneuralpp_1_1Neuron.html#ead827210fa18c2baae03927b2c798ff">00340</a> vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#ead827210fa18c2baae03927b2c798ff">in</a>;
<a name="l00341"></a><a class="code" href="classneuralpp_1_1Neuron.html#82a4297f84d6403e52a8386d26117b4f">00341</a> vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#82a4297f84d6403e52a8386d26117b4f">out</a>;
<a name="l00342"></a>00342
<a name="l00343"></a>00343 double (*<a class="code" href="classneuralpp_1_1Neuron.html#198ddd0d11a26d0052d52b787d6a0df0">actv_f</a>)(double);
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keyword">public</span>:
<a name="l00350"></a>00350 <a class="code" href="classneuralpp_1_1Neuron.html#9863a08b73bc97c8b514aca6c580ff7b" title="Constructor.">Neuron</a> (<span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>));
<a name="l00351"></a>00351
<a name="l00358"></a>00358 <a class="code" href="classneuralpp_1_1Neuron.html#9863a08b73bc97c8b514aca6c580ff7b" 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="l00359"></a>00359 <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>));
<a name="l00360"></a>00360
<a name="l00366"></a>00366 <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="l00367"></a>00367
<a name="l00373"></a>00373 <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="l00374"></a>00374
<a name="l00379"></a>00379 <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="l00380"></a>00380
<a name="l00385"></a>00385 <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="l00386"></a>00386
<a name="l00391"></a>00391 <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="l00392"></a>00392
<a name="l00397"></a>00397 <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="l00398"></a>00398
<a name="l00403"></a>00403 <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="l00404"></a>00404
<a name="l00409"></a>00409 <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="l00410"></a>00410
<a name="l00414"></a>00414 <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="l00415"></a>00415
<a name="l00420"></a>00420 <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="l00421"></a>00421
<a name="l00426"></a>00426 <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="l00427"></a>00427
<a name="l00431"></a>00431 <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="l00432"></a>00432 };
<a name="l00433"></a>00433
<a name="l00439"></a><a class="code" href="classneuralpp_1_1Layer.html">00439</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="l00440"></a><a class="code" href="classneuralpp_1_1Layer.html#855685c9da56b06b629e13a2f8c719ce">00440</a> vector&lt;Neuron&gt; <a class="code" href="classneuralpp_1_1Layer.html#855685c9da56b06b629e13a2f8c719ce">elements</a>;
<a name="l00441"></a>00441
<a name="l00442"></a>00442 void (*<a class="code" href="classneuralpp_1_1Layer.html#c023a15a16353d0b4f44060a159f550f">update_weights</a>)();
<a name="l00443"></a>00443 double (*<a class="code" href="classneuralpp_1_1Layer.html#824367da29f92253a027a7c5b4a4405e">actv_f</a>)(double);
<a name="l00444"></a>00444
<a name="l00445"></a>00445 <span class="keyword">public</span>:
<a name="l00451"></a>00451 <a class="code" href="classneuralpp_1_1Layer.html#fb08bddd85d36570dabfe915461f07c5" title="Constructor.">Layer</a> (<span class="keywordtype">size_t</span> sz, <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>));
<a name="l00452"></a>00452
<a name="l00459"></a>00459 <a class="code" href="classneuralpp_1_1Layer.html#fb08bddd85d36570dabfe915461f07c5" title="Constructor.">Layer</a> (vector&lt;Neuron&gt;&amp; neurons, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>));
<a name="l00460"></a>00460
<a name="l00466"></a>00466 <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) <span class="keywordflow">throw</span>(NetworkIndexOutOfBoundsException);
<a name="l00467"></a>00467
<a name="l00472"></a>00472 <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="l00473"></a>00473
<a name="l00478"></a>00478 <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="l00479"></a>00479
<a name="l00484"></a>00484 <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="l00485"></a>00485
<a name="l00489"></a>00489 <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="l00490"></a>00490
<a name="l00494"></a>00494 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Layer.html#7ca71ed62fbe9c1e9c0fb6a8dcaf76f0">size</a>() <span class="keyword">const</span>;
<a name="l00495"></a>00495 };
<a name="l00496"></a>00496
<a name="l00497"></a><a class="code" href="structneuralpp_1_1netrecord.html">00497</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1netrecord.html">netrecord</a> {
<a name="l00498"></a><a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">00498</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">input_size</a>;
<a name="l00499"></a><a class="code" href="structneuralpp_1_1netrecord.html#3c1728ac66c37f6ac85c404d4f55552e">00499</a> <span class="keywordtype">int</span> hidden_size;
<a name="l00500"></a><a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">00500</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">output_size</a>;
<a name="l00501"></a>00501
<a name="l00502"></a><a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">00502</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">epochs</a>;
<a name="l00503"></a><a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">00503</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">l_rate</a>;
<a name="l00504"></a><a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">00504</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">ex</a>;
<a name="l00505"></a>00505 };
<a name="l00506"></a>00506
<a name="l00507"></a><a class="code" href="structneuralpp_1_1neuronrecord.html">00507</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1neuronrecord.html">neuronrecord</a> {
<a name="l00508"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">00508</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">prop</a>;
<a name="l00509"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">00509</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">actv</a>;
<a name="l00510"></a>00510 };
<a name="l00511"></a>00511
<a name="l00512"></a><a class="code" href="structneuralpp_1_1synrecord.html">00512</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1synrecord.html">synrecord</a> {
<a name="l00513"></a><a class="code" href="structneuralpp_1_1synrecord.html#81a7dbc97eecbf5bc85cac46373a78d2">00513</a> <span class="keywordtype">double</span> w;
<a name="l00514"></a><a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">00514</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">d</a>;
<a name="l00515"></a>00515 };
<a name="l00516"></a>00516 }
<a name="l00517"></a>00517
<a name="l00518"></a>00518 <span class="comment">//#endif</span>
<a name="l00519"></a>00519 <span class="preprocessor">#endif</span>
<a name="l00520"></a>00520 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat Aug 15 02:56:02 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>