neuralpp/doc/html/neural_09_09_8hpp-source.html

244 lines
38 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>
<li><a href="examples.html"><span>Examples</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.4 - 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="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
<a name="l00024"></a><a class="code" href="neural_09_09_8hpp.html#839a9222721835f53c5b248241f535f4">00024</a> <span class="preprocessor">#define RAND (double) ( (rand() / (RAND_MAX/2)) - 1)</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00027"></a><a class="code" href="neural_09_09_8hpp.html#05e2bb5b9fc32f0b6b4d84fe43177d72">00027</a> <span class="preprocessor">#define BETA0 1.0</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00033"></a>00033 <span class="keyword">namespace </span>neuralpp {
<a name="l00034"></a>00034 <span class="keyword">class </span>Synapsis;
<a name="l00035"></a>00035 <span class="keyword">class </span>Neuron;
<a name="l00036"></a>00036 <span class="keyword">class </span>Layer;
<a name="l00037"></a>00037 <span class="keyword">class </span>NeuralNet;
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <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="l00040"></a>00040 <span class="keywordtype">double</span> <a class="code" href="namespaceneuralpp.html#7df3a0de999c7a635f2289749ed4f194">__actv</a>(<span class="keywordtype">double</span> prop);
<a name="l00041"></a>00041
<a name="l00064"></a><a class="code" href="classneuralpp_1_1NeuralNet.html">00064</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="l00065"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">00065</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4cb52dae7b43d03fac73afca7b9f3a51">epochs</a>;
<a name="l00066"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">00066</a> <span class="keywordtype">int</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#4f88106c9e542c39eac43b4ca1974a2a">ref_epochs</a>;
<a name="l00067"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">00067</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#6bd7be443e46b2fdbf1da2edb8e611ab">l_rate</a>;
<a name="l00068"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#327dbfdd72b0a74293f8f29630525aa3">00068</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#327dbfdd72b0a74293f8f29630525aa3">threshold</a>;
<a name="l00069"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#a9e4ff43427f56663739c4c7450de8ee">00069</a> std::vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#a9e4ff43427f56663739c4c7450de8ee">expect</a>;
<a name="l00070"></a>00070
<a name="l00075"></a>00075 <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="l00076"></a>00076
<a name="l00082"></a>00082 <span class="keywordtype">void</span> <a class="code" href="classneuralpp_1_1NeuralNet.html#f697a8d9967ad8f03e5a16a42cd110c5" 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>&amp; l);
<a name="l00083"></a>00083
<a name="l00089"></a>00089 <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="l00090"></a>00090
<a name="l00095"></a>00095 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="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keyword">public</span>:
<a name="l00098"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#e2b4e8405f9d25edab395d61502bdba9">00098</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="l00099"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#bbdaa1b6c0a1a95d2b18cd25fda2a266">00099</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="l00100"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#fa9b2dbcbb39d0fc70f790ac24069a74">00100</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="l00101"></a>00101
<a name="l00105"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">00105</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="l00106"></a>00106
<a name="l00110"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2">00110</a> <a class="code" href="classneuralpp_1_1NeuralNet.html#92b145f2f6f00bf1ba645ce2235882c2" title="Empty constructor for the class - it just makes nothing.">NeuralNet</a>() {}
<a name="l00111"></a>00111
<a name="l00125"></a>00125 <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="l00126"></a>00126 <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="l00127"></a>00127
<a name="l00133"></a>00133 <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="l00134"></a>00134
<a name="l00140"></a>00140 <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="l00141"></a>00141
<a name="l00146"></a>00146 <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="l00147"></a>00147
<a name="l00152"></a>00152 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="l00153"></a>00153
<a name="l00159"></a>00159 <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="l00160"></a>00160
<a name="l00166"></a>00166 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="l00167"></a>00167
<a name="l00172"></a>00172 <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="l00173"></a>00173
<a name="l00178"></a>00178 <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="l00179"></a>00179
<a name="l00185"></a>00185 <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="l00186"></a>00186
<a name="l00191"></a>00191 <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="l00192"></a>00192
<a name="l00197"></a>00197 <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="l00198"></a>00198
<a name="l00203"></a>00203 <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="l00204"></a>00204
<a name="l00211"></a>00211 <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="l00212"></a>00212
<a name="l00220"></a>00220 <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="l00221"></a>00221
<a name="l00226"></a>00226 <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="l00227"></a>00227
<a name="l00234"></a>00234 <span class="keyword">static</span> std::vector&lt;double&gt; <a class="code" href="classneuralpp_1_1NeuralNet.html#83c6555520856d5867752904349ab6ca" title="Splits a string into a vector of doubles, given a delimitator.">split</a> (<span class="keywordtype">char</span> delim, std::string <a class="code" href="classneuralpp_1_1NeuralNet.html#94c36c94060e785ea67a0014c4182f8f6d06b4fe9414a158c97aee1a3679a904">str</a>);
<a name="l00235"></a>00235
<a name="l00248"></a>00248 <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="l00249"></a>00249
<a name="l00254"></a>00254 <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="l00255"></a>00255 };
<a name="l00256"></a>00256
<a name="l00262"></a><a class="code" href="classneuralpp_1_1Synapsis.html">00262</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Synapsis.html" title="Class for managing synapsis.">Synapsis</a> {
<a name="l00263"></a><a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">00263</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#617fdc4305f8f1850eac267a7ee22660">delta</a>;
<a name="l00264"></a><a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">00264</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#65471cd6c9ef87609dfa4b0e5fafa708">prev_delta</a>;
<a name="l00265"></a><a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">00265</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Synapsis.html#0bc523a8135ebbb5c0da932939d30ed7">weight</a>;
<a name="l00266"></a>00266
<a name="l00267"></a><a class="code" href="classneuralpp_1_1Synapsis.html#83d41c158054b08bd05051736e89a0ad">00267</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="l00268"></a><a class="code" href="classneuralpp_1_1Synapsis.html#fb219e05038fa0da20db1082ab0500be">00268</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="l00269"></a>00269
<a name="l00270"></a>00270 double (*<a class="code" href="classneuralpp_1_1Synapsis.html#2539b9eef2ff0f3522aea8d89e394f02">actv_f</a>)(double);
<a name="l00271"></a>00271
<a name="l00272"></a>00272 <span class="keyword">public</span>:
<a name="l00280"></a>00280 <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="l00281"></a>00281
<a name="l00288"></a>00288 <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="l00289"></a>00289
<a name="l00297"></a>00297 <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="l00298"></a>00298 <span class="keywordtype">double</span> w, <span class="keywordtype">double</span>(*a)(<span class="keywordtype">double</span>));
<a name="l00299"></a>00299
<a name="l00303"></a>00303 <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="l00304"></a>00304
<a name="l00308"></a>00308 <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="l00309"></a>00309
<a name="l00314"></a>00314 <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="l00315"></a>00315
<a name="l00321"></a>00321 <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="l00322"></a>00322
<a name="l00327"></a>00327 <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="l00328"></a>00328
<a name="l00333"></a>00333 <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="l00334"></a>00334
<a name="l00339"></a>00339 <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="l00340"></a>00340
<a name="l00351"></a>00351 <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="l00352"></a>00352 };
<a name="l00353"></a>00353
<a name="l00359"></a><a class="code" href="classneuralpp_1_1Neuron.html">00359</a> <span class="keyword">class </span><a class="code" href="classneuralpp_1_1Neuron.html" title="Class for managing neurons.">Neuron</a> {
<a name="l00360"></a><a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">00360</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#eec680c47272b2465e8d8a998c359853">actv_val</a>;
<a name="l00361"></a><a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">00361</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#da75259de98b1a893c736666af6bfdc3">prop_val</a>;
<a name="l00362"></a><a class="code" href="classneuralpp_1_1Neuron.html#7b16632868821d73dedcb8edaf6dbbef">00362</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Neuron.html#7b16632868821d73dedcb8edaf6dbbef">threshold</a>;
<a name="l00363"></a>00363
<a name="l00364"></a><a class="code" href="classneuralpp_1_1Neuron.html#bd07357465bb7b29bb344400e9e08710">00364</a> std::vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#bd07357465bb7b29bb344400e9e08710">in</a>;
<a name="l00365"></a><a class="code" href="classneuralpp_1_1Neuron.html#982aceef324b7764e778d5949720bc55">00365</a> std::vector&lt; Synapsis &gt; <a class="code" href="classneuralpp_1_1Neuron.html#982aceef324b7764e778d5949720bc55">out</a>;
<a name="l00366"></a>00366
<a name="l00367"></a>00367 double (*<a class="code" href="classneuralpp_1_1Neuron.html#198ddd0d11a26d0052d52b787d6a0df0">actv_f</a>)(double);
<a name="l00368"></a>00368
<a name="l00369"></a>00369 <span class="keyword">public</span>:
<a name="l00376"></a>00376 <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="l00377"></a>00377
<a name="l00386"></a>00386 <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="l00387"></a>00387 <span class="keywordtype">double</span> (*a)(<span class="keywordtype">double</span>), <span class="keywordtype">double</span> th = 0.0);
<a name="l00388"></a>00388
<a name="l00394"></a>00394 <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="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#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="l00402"></a>00402
<a name="l00407"></a>00407 <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="l00408"></a>00408
<a name="l00413"></a>00413 <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="l00414"></a>00414
<a name="l00419"></a>00419 <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="l00420"></a>00420
<a name="l00425"></a>00425 <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="l00426"></a>00426
<a name="l00431"></a>00431 <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="l00432"></a>00432
<a name="l00437"></a>00437 <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="l00438"></a>00438
<a name="l00442"></a>00442 <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="l00443"></a>00443
<a name="l00448"></a>00448 <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="l00449"></a>00449
<a name="l00454"></a>00454 <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="l00455"></a>00455
<a name="l00459"></a>00459 <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="l00460"></a>00460 };
<a name="l00461"></a>00461
<a name="l00467"></a><a class="code" href="classneuralpp_1_1Layer.html">00467</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="l00468"></a><a class="code" href="classneuralpp_1_1Layer.html#8188cb5c264e6021cee9979b968a0305">00468</a> std::vector&lt;Neuron&gt; <a class="code" href="classneuralpp_1_1Layer.html#8188cb5c264e6021cee9979b968a0305">elements</a>;
<a name="l00469"></a><a class="code" href="classneuralpp_1_1Layer.html#02cf4efe1da02a7404d25375c85ed71f">00469</a> <span class="keywordtype">double</span> <a class="code" href="classneuralpp_1_1Layer.html#02cf4efe1da02a7404d25375c85ed71f">threshold</a>;
<a name="l00470"></a>00470
<a name="l00471"></a>00471 void (*<a class="code" href="classneuralpp_1_1Layer.html#c023a15a16353d0b4f44060a159f550f">update_weights</a>)();
<a name="l00472"></a>00472 double (*<a class="code" href="classneuralpp_1_1Layer.html#824367da29f92253a027a7c5b4a4405e">actv_f</a>)(double);
<a name="l00473"></a>00473
<a name="l00474"></a>00474 <span class="keyword">public</span>:
<a name="l00482"></a>00482 <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="l00483"></a>00483
<a name="l00492"></a>00492 <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="l00493"></a>00493
<a name="l00499"></a>00499 <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="l00500"></a>00500
<a name="l00505"></a>00505 <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="l00506"></a>00506
<a name="l00511"></a>00511 <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="l00512"></a>00512
<a name="l00516"></a>00516 <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="l00517"></a>00517
<a name="l00521"></a>00521 <span class="keywordtype">size_t</span> <a class="code" href="classneuralpp_1_1Layer.html#7ca71ed62fbe9c1e9c0fb6a8dcaf76f0">size</a>() <span class="keyword">const</span>;
<a name="l00522"></a>00522 };
<a name="l00523"></a>00523
<a name="l00524"></a><a class="code" href="structneuralpp_1_1netrecord.html">00524</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1netrecord.html">netrecord</a> {
<a name="l00525"></a><a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">00525</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#e1f480bfef05033accef40f77c09fa87">input_size</a>;
<a name="l00526"></a><a class="code" href="structneuralpp_1_1netrecord.html#3c1728ac66c37f6ac85c404d4f55552e">00526</a> <span class="keywordtype">int</span> hidden_size;
<a name="l00527"></a><a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">00527</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#95f2b0651dd3a0e5e7201ff354e401b4">output_size</a>;
<a name="l00528"></a>00528
<a name="l00529"></a><a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">00529</a> <span class="keywordtype">int</span> <a class="code" href="structneuralpp_1_1netrecord.html#ab0149ed5ea0694e88213a07cd4427d1">epochs</a>;
<a name="l00530"></a><a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">00530</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#a4f793a39a40144e811fef4d3d2d2b30">l_rate</a>;
<a name="l00531"></a><a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">00531</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1netrecord.html#dcc44fde3f67058d26ef2d5cbd0904e6">ex</a>;
<a name="l00532"></a>00532 };
<a name="l00533"></a>00533
<a name="l00534"></a><a class="code" href="structneuralpp_1_1neuronrecord.html">00534</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1neuronrecord.html">neuronrecord</a> {
<a name="l00535"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#30b298a95939b88b565fefc2dc57e89d">00535</a> <span class="keywordtype">double</span> prop;
<a name="l00536"></a><a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">00536</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1neuronrecord.html#15201b190584987255d81d4b7e773375">actv</a>;
<a name="l00537"></a>00537 };
<a name="l00538"></a>00538
<a name="l00539"></a><a class="code" href="structneuralpp_1_1synrecord.html">00539</a> <span class="keyword">struct </span><a class="code" href="structneuralpp_1_1synrecord.html">synrecord</a> {
<a name="l00540"></a><a class="code" href="structneuralpp_1_1synrecord.html#81a7dbc97eecbf5bc85cac46373a78d2">00540</a> <span class="keywordtype">double</span> w;
<a name="l00541"></a><a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">00541</a> <span class="keywordtype">double</span> <a class="code" href="structneuralpp_1_1synrecord.html#3a862082dfa0edffce84936818bab374">d</a>;
<a name="l00542"></a>00542 };
<a name="l00543"></a>00543 }
<a name="l00544"></a>00544
<a name="l00545"></a>00545 <span class="preprocessor">#endif</span>
<a name="l00546"></a>00546 <span class="preprocessor"></span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 16 20:53:42 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>