<h1>examples/learnAdd.cpp</h1>Show how to train a network that performs sums between two real numbers. The training XML is built from scratch, then saved to a file, then the network is initialized using that XML file, trained, and the resulting trained network is saved to adder.net. Then, you should take a look at doAdd.cpp to see how to use that file to use the network.<p>
<spanclass="comment">// => a learning rate == 0.002 (just get it doing some tests until satisfied, but remember to keep its value quite low and ~ 0 to keep the network stable)</span>
cout <<<spanclass="stringliteral">"Training file adder.xml has been written\n"</span>;
<spanclass="comment">// Start the training from the XML file</span>
t1 = time(NULL);
cout <<<spanclass="stringliteral">"Training in progress - This may take a while...\n"</span>;
net.<aname="a1"></a><aclass="code"href="classneuralpp_1_1NeuralNet.html#1c9e17437d41a7048611e21a3cc1c7dd"title="Train a network using a training set loaded from an XML file.">train</a>(<spanclass="stringliteral">"adder.xml"</span>, NeuralNet::file);
t2 = time(NULL);
<spanclass="comment">// Save the trained network to a binary file, that can be reloaded from any</span>
<spanclass="comment">// application that is going to use that network</span>
net.<aname="a2"></a><aclass="code"href="classneuralpp_1_1NeuralNet.html#fdf94c276720c25e565cac834fe8a407"title="Save a trained neural network to a binary file.">save</a>(<spanclass="stringliteral">"network.xml"</span>);
cout <<<spanclass="stringliteral">"Network trained in "</span><< (t2-t1) <<<spanclass="stringliteral">" seconds. You can use adder.net file now to load this network\n"</span>;