mirror of
https://github.com/BlackLight/neuralpp.git
synced 2025-07-09 16:48:08 +02:00
Is it time to release 1.0 version?
This commit is contained in:
parent
89b0ad2f8a
commit
a7fa05ba40
140 changed files with 1710 additions and 829 deletions
|
@ -0,0 +1,66 @@
|
|||
<!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++: examples/networkForSumsAndSubtractions.cpp</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 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><a href="files.html"><span>Files</span></a></li>
|
||||
<li><a href="examples.html"><span>Examples</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="contents">
|
||||
<h1>examples/networkForSumsAndSubtractions.cpp</h1>This program creates a neural network from scratch. Its purpose is to get two numbers and learn to compute their sum and difference (so the network provides two output values). The training set is auto-generated to an XML string, and then the network is trained.<p>
|
||||
<div class="fragment"><pre class="fragment">
|
||||
<span class="preprocessor">#include <iostream></span>
|
||||
<span class="preprocessor">#include <<a class="code" href="neural_09_09_8hpp.html">neural++.hpp</a>></span>
|
||||
|
||||
<span class="keyword">using namespace </span>std;
|
||||
<span class="keyword">using namespace </span>neuralpp;
|
||||
|
||||
<span class="keywordtype">int</span> main() {
|
||||
<a name="_a0"></a><a class="code" href="classneuralpp_1_1NeuralNet.html" title="Main project&#39;s class.">NeuralNet</a> net(2, 2, 2, 0.002, 1000);
|
||||
<span class="keywordtype">string</span> xml;
|
||||
<span class="keywordtype">double</span> tmp;
|
||||
<span class="keywordtype">int</span> <span class="keywordtype">id</span> = 0;
|
||||
|
||||
<span class="comment">// XML initialization. Then, I say XML that 3+2=5, 3-2=1; 4+2=6, 4-2=2; 6+3=9, 6-3=3</span>
|
||||
<span class="comment">// Strings' format is "input1,input2,...,inputn;output1,output2,...,outputm</span>
|
||||
NeuralNet::initXML(xml);
|
||||
xml += NeuralNet::XMLFromSet(<span class="keywordtype">id</span>, <span class="stringliteral">"3,2;5,1"</span>);
|
||||
xml += NeuralNet::XMLFromSet(<span class="keywordtype">id</span>, <span class="stringliteral">"4,2;6,2"</span>);
|
||||
xml += NeuralNet::XMLFromSet(<span class="keywordtype">id</span>, <span class="stringliteral">"6,3;9,3"</span>);
|
||||
NeuralNet::closeXML(xml);
|
||||
cout << xml << endl;
|
||||
|
||||
net.<a name="a1"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#1c9e17437d41a7048611e21a3cc1c7dd" title="Train a network using a training set loaded from an XML file.">train</a>(xml, NeuralNet::str);
|
||||
vector<double> v;
|
||||
cout << <span class="stringliteral">"Network status: trained\n\n"</span>;
|
||||
|
||||
cout << <span class="stringliteral">"First number: "</span>;
|
||||
cin >> tmp;
|
||||
v.push_back(tmp);
|
||||
|
||||
cout << <span class="stringliteral">"Second number: "</span>;
|
||||
cin >> tmp;
|
||||
v.push_back(tmp);
|
||||
|
||||
net.<a name="a2"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#405b32d2928344314ecf0469070b0f17" title="It sets the input for the network.">setInput</a>(v);
|
||||
net.<a name="a3"></a><a class="code" href="classneuralpp_1_1NeuralNet.html#c129c180647362da963758bfd1ba6890" title="It propagates values through the network.">propagate</a>();
|
||||
cout << <span class="stringliteral">"Output: "</span> << net.<a name="a4"></a><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>()[0] << <span class="stringliteral">"; "</span> << net.<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>()[1] << endl;
|
||||
<span class="keywordflow">return</span> 0;
|
||||
}
|
||||
|
||||
</pre></div> </div>
|
||||
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Sep 4 11:25:49 2009 for Neural++ by
|
||||
<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>
|
Loading…
Add table
Add a link
Reference in a new issue