neuralpp/doc/html/neural_09_09_8hpp-source.html

257 lines
40 KiB
HTML
Raw Normal View History

2009-08-09 11:17:39 +02:00
<!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>
<li><a href="examples.html"><span>Examples</span></a></li>
2009-08-09 11:17:39 +02:00
</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.4 - All-purpose library for managing neural networks *</span>
2009-08-09 11:17:39 +02:00
<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="preprocessor">#ifndef __NEURALPP</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define __NEURALPP</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;cmath&gt;</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="neural_09_09__exception_8hpp.html">neural++_exception.hpp</a>"</span>
<a name="l00022"></a>00022
2009-09-04 11:27:14 +02:00
<a name="l00023"></a><a class="code" href="neural_09_09_8hpp.html#839a9222721835f53c5b248241f535f4">00023</a> <span class="preprocessor">#define RAND (double) ( (rand() / 10.0) / ((double) RAND_MAX) )</span>
<a name="l00024"></a><a class="code" href="neural_09_09_8hpp.html#05e2bb5b9fc32f0b6b4d84fe43177d72">00024</a> <span class="preprocessor"></span><span class="preprocessor">#define BETA0 0.8</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
2009-09-04 11:27:14 +02:00
<a name="l00030"></a>00030 <span class="keyword">namespace </span>neuralpp {
<a name="l00031"></a>00031 <span class="keyword">class </span>Synapsis;
<a name="l00032"></a>00032 <span class="keyword">class </span>Neuron;
<a name="l00033"></a>00033 <span class="keyword">class </span>Layer;
<a name="l00034"></a>00034 <span class="keyword">class </span>NeuralNet;
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <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="l00037"></a>00037 <span class="keywordtype">double</span> <a class="code" href="namespaceneuralpp.html#7df3a0de999c7a635f2289749ed4f194">__actv</a>(<span class="keywordtype">double</span> prop);
<a name="l00038"></a>00038
2009-09-04 11:27:14 +02:00
<a name="l00067"></a><a class="code" href="classneuralpp_1_1NeuralNet.html">00067</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="l00068"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">00068</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">epochs</a>;
<a name="l00069"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">00069</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">ref_epochs</a>;
<a name="l00070"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">00070</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">l_rate</a>;
<a name="l00071"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#327dbfdd72b0a74293f8f29630525aa3">00071</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#327dbfdd72b0a74293f8f29630525aa3">threshold</a>;
<a name="l00072"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#a9e4ff43427f56663739c4c7450de8ee">00072</a> std::vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#a9e4ff43427f56663739c4c7450de8ee">expect</a>;
<a name="l00073"></a>00073
<a name="l00078"></a>00078 <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="l00079"></a>00079
<a name="l00085"></a>00085 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#8a140d28e6dd4097470c7c138801ad01" title="Get the error made on the expected result as squared deviance.">error</a> (<span class="keywordtype">double</span> ex);
<a name="l00086"></a>00086
<a name="l00091"></a>00091 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="l00092"></a>00092
<a name="l00098"></a>00098 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#562dfe9fb8d73bf25a23ce608451d3aa" title="Get the expected value (in case you have an only neuron in output layer).">expected</a>() <span class="keyword">const</span>;
<a name="l00099"></a>00099
<a name="l00105"></a>00105 std::vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#51a1851ed07b85bec091c9053ae99cf7" title="Get the expected value (in case you have an only neuron in output layer).">getExpected</a>() <span class="keyword">const</span>;
<a name="l00106"></a>00106
2009-09-04 11:27:14 +02:00
<a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#b6475762b7e9eab086befdc511f7c236" title="It sets the value you expect from your network (in case the network has an only neuron...">setExpected</a>(<span class="keywordtype">double</span> ex);
<a name="l00112"></a>00112
<a name="l00117"></a>00117 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#b6475762b7e9eab086befdc511f7c236" title="It sets the value you expect from your network (in case the network has an only neuron...">setExpected</a>(std::vector&lt;double&gt; ex);
<a name="l00118"></a>00118
<a name="l00124"></a>00124 <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="l00125"></a>00125
<a name="l00129"></a>00129 <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="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keyword">public</span>:
<a name="l00132"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#e2b4e8405f9d25edab395d61502bdba9">00132</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="l00133"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#bbdaa1b6c0a1a95d2b18cd25fda2a266">00133</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="l00134"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#fa9b2dbcbb39d0fc70f790ac24069a74">00134</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="l00135"></a>00135
<a name="l00139"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">00139</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="l00140"></a>00140
<a name="l00144"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2">00144</a> <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a>() {}
<a name="l00145"></a>00145
<a name="l00159"></a>00159 <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,
<a name="l00160"></a>00160 <span class="keywordtype">int</span> e, <span class="keywordtype">double</span> th = 0.0, <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>) = __actv);
<a name="l00161"></a>00161
<a name="l00167"></a>00167 <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> std::string <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f5ec2727c0756ddb097b53efe49b81afb">file</a>) <span class="keywordflow">throw</span>(<a class="code" href="classneuralpp_1_1NetworkFileNotFoundException.html" title="Exception thrown when doing an attempt to load a network from an invalid file.">NetworkFileNotFoundException</a>);
<a name="l00168"></a>00168
<a name="l00174"></a>00174 <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="l00175"></a>00175
<a name="l00180"></a>00180 std::vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#e6d2215ecc8b560db2f6797db642191c" title="It gets the output of the network in case the output layer contains more neurons...">getOutputs</a>();
<a name="l00181"></a>00181
<a name="l00186"></a>00186 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#e08cdcf4b70f987700e553d9914f6179" title="Get the threshold of the neurons in the network.">getThreshold</a>() <span class="keyword">const</span>;
<a name="l00187"></a>00187
<a name="l00192"></a>00192 <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="l00193"></a>00193
<a name="l00198"></a>00198 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#405b32d2928344314ecf0469070b0f17" title="It sets the input for the network.">setInput</a> (std::vector&lt;double&gt; v);
<a name="l00199"></a>00199
<a name="l00206"></a>00206 <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>(<a class="code" href="classneuralpp_1_1NetworkFileWriteException.html" title="Exception thrown when trying to write the network&amp;#39;s information to a file that...">NetworkFileWriteException</a>);
<a name="l00207"></a>00207
<a name="l00218"></a>00218 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#a060e28b438613a6cc9e0895ddbc292b" title="DEPRECATED.">loadFromBinary</a> (<span class="keyword">const</span> std::string fname) <span class="keywordflow">throw</span>(<a class="code" href="classneuralpp_1_1NetworkFileNotFoundException.html" title="Exception thrown when doing an attempt to load a network from an invalid file.">NetworkFileNotFoundException</a>);
<a name="l00219"></a>00219
<a name="l00230"></a>00230 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#520147d9b47b69565567bd3fdcfd8897" title="DEPRECATED.">saveToBinary</a> (<span class="keyword">const</span> <span class="keywordtype">char</span>* fname) <span class="keywordflow">throw</span>(<a class="code" href="classneuralpp_1_1NetworkFileWriteException.html" title="Exception thrown when trying to write the network&amp;#39;s information to a file that...">NetworkFileWriteException</a>);
<a name="l00231"></a>00231
<a name="l00239"></a>00239 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#1c9e17437d41a7048611e21a3cc1c7dd" title="Train a network using a training set loaded from an XML file.">train</a> (std::string 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>(<a class="code" href="classneuralpp_1_1InvalidXMLException.html" title="Exception thrown when trying parsing an invalid XML.">InvalidXMLException</a>);
<a name="l00240"></a>00240
<a name="l00245"></a>00245 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#96da6712a72051cf34ad961761ef6e08" title="Initialize the training XML for the neural network.">initXML</a> (std::string&amp; xml);
<a name="l00246"></a>00246
<a name="l00259"></a>00259 <span class="keyword">static</span> std::string <a class="code" href="classneuralpp_1_1NeuralNet.html#0a2733037af912b3e6a10146e7b7172f" 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>&amp; <span class="keywordtype">id</span>, std::string <span class="keyword">set</span>);
<a name="l00260"></a>00260
<a name="l00265"></a>00265 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#e17732ed578bc4bd6032bfae58a5cf51" title="Closes an open XML document generated by &amp;quot;initXML&amp;quot; and &amp;quot;XMLFromSet&amp;quot;...">closeXML</a>(std::string&amp; xml);
<a name="l00266"></a>00266 };
<a name="l00267"></a>00267
<a name="l00273"></a><a class="code" href="classneuralpp_1_1Synapsis.html">00273</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a> {
<a name="l00274"></a><a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">00274</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">delta</a>;
<a name="l00275"></a><a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">00275</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">prev_delta</a>;
<a name="l00276"></a><a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">00276</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">weight</a>;
<a name="l00277"></a>00277
<a name="l00278"></a><a class="code" href="classneuralpp_1_1Synapsis.html#83d41c158054b08bd05051736e89a0ad">00278</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="l00279"></a><a class="code" href="classneuralpp_1_1Synapsis.html#fb219e05038fa0da20db1082ab0500be">00279</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="l00280"></a>00280
<a name="l00281"></a>00281 double (*<a class="code" href="classneuralpp_1_1Synapsis.html#2539b9eef2ff0f3522aea8d89e394f02">actv_f</a>)(double);
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keyword">public</span>:
<a name="l00287"></a><a class="code" href="classneuralpp_1_1Synapsis.html#c7760b19c56e9f69994970311703c5fa">00287</a> <a class="code" href="classneuralpp_1_1Synapsis.html#c7760b19c56e9f69994970311703c5fa" title="Empty constructor (it does nothing).">Synapsis</a>() {}
<a name="l00288"></a>00288
<a name="l00295"></a>00295 <a class="code" href="classneuralpp_1_1Synapsis.html#c7760b19c56e9f69994970311703c5fa" title="Empty constructor (it does nothing).">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="l00296"></a>00296
<a name="l00304"></a>00304 <a class="code" href="classneuralpp_1_1Synapsis.html#c7760b19c56e9f69994970311703c5fa" title="Empty constructor (it does nothing).">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="l00305"></a>00305 <span class="keywordtype">double</span> w, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>));
<a name="l00306"></a>00306
<a name="l00310"></a>00310 <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* <a class="code" href="classneuralpp_1_1Synapsis.html#298fd3c7483ad572899fecec01ac8fdf">getIn</a>() <span class="keyword">const</span>;
<a name="l00311"></a>00311
<a name="l00315"></a>00315 <a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a>* <a class="code" href="classneuralpp_1_1Synapsis.html#b46d876761a73a24db87f5a144a0e899">getOut</a>() <span class="keyword">const</span>;
<a name="l00316"></a>00316
<a name="l00321"></a>00321 <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>(<a class="code" href="classneuralpp_1_1InvalidSynapticalWeightException.html" title="Exception raised when, while trying the network or directly, the weight of a synapsis...">InvalidSynapticalWeightException</a>);
<a name="l00322"></a>00322
<a name="l00328"></a>00328 <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>(<a class="code" href="classneuralpp_1_1InvalidSynapticalWeightException.html" title="Exception raised when, while trying the network or directly, the weight of a synapsis...">InvalidSynapticalWeightException</a>);
<a name="l00329"></a>00329
<a name="l00334"></a>00334 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#bcbf7228632ff4d6bbb67703323d2db0" title="Return the weight of the synapsis.">getWeight</a>() <span class="keyword">const</span>;
<a name="l00335"></a>00335
<a name="l00340"></a>00340 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#00c8e9c0804662f2b3247d6dddb4ca6c" title="Return the delta of the synapsis.">getDelta</a>() <span class="keyword">const</span>;
<a name="l00341"></a>00341
<a name="l00346"></a>00346 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#0148b9c8db870c928711168702ae51c5" title="Get the delta of the synapsis at the previous iteration.">getPrevDelta</a>() <span class="keyword">const</span>;
<a name="l00347"></a>00347
<a name="l00358"></a>00358 <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#cff10a022d4c021688e4df944c05d8bd" title="Get the inertial momentum of a synapsis.">momentum</a> (<span class="keywordtype">int</span> N, <span class="keywordtype">int</span> x) <span class="keyword">const</span>;
<a name="l00359"></a>00359 };
<a name="l00360"></a>00360
<a name="l00366"></a><a class="code" href="classneuralpp_1_1Neuron.html">00366</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> {
<a name="l00367"></a><a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">00367</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">actv_val</a>;
<a name="l00368"></a><a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">00368</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">prop_val</a>;
<a name="l00369"></a><a class="code" href="classneuralpp_1_1Neuron.html#7b16632868821d73dedcb8edaf6dbbef">00369</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#7b16632868821d73dedcb8edaf6dbbef">threshold</a>;
<a name="l00370"></a>00370
<a name="l00371"></a><a class="code" href="classneuralpp_1_1Neuron.html#bd07357465bb7b29bb344400e9e08710">00371</a> std::vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#bd07357465bb7b29bb344400e9e08710">in</a>;
<a name="l00372"></a><a class="code" href="classneuralpp_1_1Neuron.html#982aceef324b7764e778d5949720bc55">00372</a> std::vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#982aceef324b7764e778d5949720bc55">out</a>;
<a name="l00373"></a>00373
<a name="l00374"></a>00374 double (*<a class="code" href="classneuralpp_1_1Neuron.html#198ddd0d11a26d0052d52b787d6a0df0">actv_f</a>)(double);
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keyword">public</span>:
<a name="l00383"></a>00383 <a class="code" href="classneuralpp_1_1Neuron.html#c9bd4f5f618fcf1adcebf1ab63ee0960" title="Constructor.">Neuron</a> (<span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> th = 0.0);
<a name="l00384"></a>00384
<a name="l00393"></a>00393 <a class="code" href="classneuralpp_1_1Neuron.html#c9bd4f5f618fcf1adcebf1ab63ee0960" title="Constructor.">Neuron</a> (std::vector&lt;Synapsis&gt; <a class="code" href="classneuralpp_1_1Neuron.html#bd07357465bb7b29bb344400e9e08710">in</a>, std::vector&lt;Synapsis&gt; <a class="code" href="classneuralpp_1_1Neuron.html#982aceef324b7764e778d5949720bc55">out</a>,
<a name="l00394"></a>00394 <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> th = 0.0);
<a name="l00395"></a>00395
<a name="l00401"></a>00401 <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="l00402"></a>00402
<a name="l00408"></a>00408 <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="l00409"></a>00409
<a name="l00414"></a>00414 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#4d252151c35839975838539d846d70be" 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> s);
<a name="l00415"></a>00415
<a name="l00420"></a>00420 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#2c0acb0e6d413c4e0fc9e7939da1a684" 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> s);
<a name="l00421"></a>00421
<a name="l00426"></a>00426 <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="l00427"></a>00427
<a name="l00432"></a>00432 <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="l00433"></a>00433
<a name="l00434"></a>00434 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#6fa3e8afc1c6e6e427773ba89a6fcb68">setSynIn</a> (<span class="keywordtype">size_t</span> n);
<a name="l00435"></a>00435 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#d6ae3a93ecd11c345d931aee4ca248c1">setSynOut</a> (<span class="keywordtype">size_t</span> n);
<a name="l00436"></a>00436
<a name="l00441"></a>00441 <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="l00442"></a>00442
<a name="l00447"></a>00447 <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="l00448"></a>00448
<a name="l00452"></a>00452 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Neuron.html#928d9bf5aed600119c640779e4034f30" title="Compute the propagation value of the neuron and set it.">propagate</a>();
<a name="l00453"></a>00453
<a name="l00458"></a>00458 <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="l00459"></a>00459
<a name="l00464"></a>00464 <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="l00465"></a>00465
<a name="l00469"></a>00469 <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="l00470"></a>00470 };
<a name="l00471"></a>00471
<a name="l00477"></a><a class="code" href="classneuralpp_1_1Layer.html">00477</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="l00478"></a><a class="code" href="classneuralpp_1_1Layer.html#8188cb5c264e6021cee9979b968a0305">00478</a> std::vector&lt;Neuron&gt; <a class="code" href="classneuralpp_1_1Layer.html#8188cb5c264e6021cee9979b968a0305">elements</a>;
<a name="l00479"></a><a class="code" href="classneuralpp_1_1Layer.html#02cf4efe1da02a7404d25375c85ed71f">00479</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Layer.html#02cf4efe1da02a7404d25375c85ed71f">threshold</a>;
<a name="l00480"></a>00480
<a name="l00481"></a>00481 void (*<a class="code" href="classneuralpp_1_1Layer.html#c023a15a16353d0b4f44060a159f550f">update_weights</a>)();
<a name="l00482"></a>00482 double (*<a class="code" href="classneuralpp_1_1Layer.html#824367da29f92253a027a7c5b4a4405e">actv_f</a>)(double);
<a name="l00483"></a>00483
2009-09-04 11:27:14 +02:00
<a name="l00484"></a>00484 <span class="keyword">public</span>:
<a name="l00492"></a>00492 <a class="code" href="classneuralpp_1_1Layer.html#a235767701b5e9dcf28c5e9e0d04cb0b" 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> th = 0.0);
<a name="l00493"></a>00493
2009-09-04 11:27:14 +02:00
<a name="l00502"></a>00502 <a class="code" href="classneuralpp_1_1Layer.html#a235767701b5e9dcf28c5e9e0d04cb0b" title="Constructor.">Layer</a> (std::vector&lt;Neuron&gt;&amp; neurons, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> th = 0.0);
<a name="l00503"></a>00503
<a name="l00509"></a>00509 <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>(<a class="code" href="classneuralpp_1_1NetworkIndexOutOfBoundsException.html" title="Exception raised when trying to access a neuron whose index is larger than the number...">NetworkIndexOutOfBoundsException</a>);
<a name="l00510"></a>00510
<a name="l00515"></a>00515 <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="l00516"></a>00516
<a name="l00521"></a>00521 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1Layer.html#88ceffc23f02a9dc24d4355767b7cca7" title="Set the input values for the neurons of the layer (just use it for the input layer)...">setInput</a> (std::vector&lt;double&gt; v);
<a name="l00522"></a>00522
<a name="l00526"></a>00526 <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="l00527"></a>00527
<a name="l00531"></a>00531 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Layer.html#7ca71ed62fbe9c1e9c0fb6a8dcaf76f0">size</a>() <span class="keyword">const</span>;
<a name="l00532"></a>00532 };
<a name="l00533"></a>00533
2009-09-04 11:27:14 +02:00
<a name="l00534"></a><a class="code" href="structneuralpp_1_1netrecord.html">00534</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1netrecord.html">netrecord</a> {
<a name="l00535"></a><a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">00535</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">input_size</a>;
<a name="l00536"></a><a class="code" href="structneuralpp_1_1netrecord.html#3c1728ac66c37f6ac85c404d4f55552e">00536</a> <span class="keywordtype">int</span> hidden_size;
<a name="l00537"></a><a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">00537</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">output_size</a>;
<a name="l00538"></a>00538
2009-09-04 11:27:14 +02:00
<a name="l00539"></a><a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">00539</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">epochs</a>;
<a name="l00540"></a><a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">00540</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">l_rate</a>;
<a name="l00541"></a><a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">00541</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">ex</a>;
<a name="l00542"></a>00542 };
2009-09-04 11:27:14 +02:00
<a name="l00543"></a>00543
<a name="l00544"></a><a class="code" href="structneuralpp_1_1neuronrecord.html">00544</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1neuronrecord.html">neuronrecord</a> {
<a name="l00545"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">00545</a> <span class="keywordtype">double</span> prop;
<a name="l00546"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">00546</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">actv</a>;
<a name="l00547"></a>00547 };
<a name="l00548"></a>00548
<a name="l00549"></a><a class="code" href="structneuralpp_1_1synrecord.html">00549</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1synrecord.html">synrecord</a> {
<a name="l00550"></a><a class="code" href="structneuralpp_1_1synrecord.html#81a7dbc97eecbf5bc85cac46373a78d2">00550</a> <span class="keywordtype">double</span> w;
<a name="l00551"></a><a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">00551</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">d</a>;
<a name="l00552"></a>00552 };
<a name="l00553"></a>00553
<a name="l00554"></a><a class="code" href="namespaceneuralpp_1_1neuralutils.html">00554</a> <span class="keyword">namespace </span>neuralutils {
<a name="l00561"></a>00561 std::vector&lt;double&gt; <a class="code" href="namespaceneuralpp_1_1neuralutils.html#68719b3d63ca48ed264e1b730a1aaa4a" title="Split a string into a vector of doubles, given a delimitator.">split</a> (<span class="keywordtype">char</span> delim, std::string str);
<a name="l00562"></a>00562
<a name="l00568"></a>00568 std::vector&lt;std::string&gt; <a class="code" href="namespaceneuralpp_1_1neuralutils.html#1d887e4bcc7ef2d50cbeca984767a78b" title="Split the lines of a string.">splitLines</a> (std::string str);
<a name="l00569"></a>00569
<a name="l00574"></a>00574 <span class="keywordtype">void</span> <a class="code" href="namespaceneuralpp_1_1neuralutils.html#f7932c25bd82b19173d2f3d2e5cef488" title="Convert the characters of a string to lower case.">toLower</a> (std::string&amp; str);
<a name="l00575"></a>00575
<a name="l00580"></a>00580 <span class="keywordtype">void</span> <a class="code" href="namespaceneuralpp_1_1neuralutils.html#265b22d1a6110646b42693b96c21ca8b" title="Convert the characters of a string to upper case.">toUpper</a> (std::string&amp; str);
<a name="l00581"></a>00581 }
<a name="l00582"></a>00582 }
<a name="l00583"></a>00583
<a name="l00584"></a>00584 <span class="preprocessor">#endif</span>
<a name="l00585"></a>00585 <span class="preprocessor"></span>
2009-08-09 11:17:39 +02:00
</pre></div></div>
2009-09-04 11:27:14 +02:00
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Sep 4 11:25:49 2009 for Neural++ by&nbsp;
2009-08-09 11:17:39 +02:00
<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>