It finally supports multiple outputs for the network

This commit is contained in:
blacklight 2009-08-16 16:02:21 +02:00
parent 73f13abb56
commit adfa58800f
7 changed files with 36 additions and 37 deletions

View file

@ -10,22 +10,25 @@
-->
<NETWORK NAME="adder">
<TRAINING ID="1">
<INPUT ID="0">2</INPUT>
<TRAINING ID="0">
<INPUT ID="1">3</INPUT>
<OUTPUT ID="0">5</OUTPUT>
<INPUT ID="2">2</INPUT>
<OUTPUT ID="3">5</OUTPUT>
<OUTPUT ID="4">1</OUTPUT>
</TRAINING>
<TRAINING ID="1">
<INPUT ID="0">3</INPUT>
<INPUT ID="1">4</INPUT>
<OUTPUT ID="0">7</OUTPUT>
<TRAINING ID="5">
<INPUT ID="6">5</INPUT>
<INPUT ID="7">3</INPUT>
<OUTPUT ID="8">8</OUTPUT>
<OUTPUT ID="9">2</OUTPUT>
</TRAINING>
<TRAINING ID="2">
<INPUT ID="0">10</INPUT>
<INPUT ID="1">10</INPUT>
<OUTPUT ID="0">20</OUTPUT>
<TRAINING ID="10">
<INPUT ID="11">6</INPUT>
<INPUT ID="12">3</INPUT>
<OUTPUT ID="13">9</OUTPUT>
<OUTPUT ID="14">3</OUTPUT>
</TRAINING>
</NETWORK>

View file

@ -12,17 +12,18 @@ using namespace std;
using namespace neuralpp;
int main() {
NeuralNet net(3, 3, 1, 0.005, 1000);
NeuralNet net(2, 2, 2, 0.005, 1000);
string xml;
double tmp;
// XML initialization. Then, I say XML that 2+3=5, 3+3=6, 5+4=9
// Strings' format is "input1,input2,...,inputn;output1,output2,...,outputm
NeuralNet::initXML(xml);
xml += NeuralNet::XMLFromSet(0, "2,3,4;9");
xml += NeuralNet::XMLFromSet(1, "3,3,1;7");
xml += NeuralNet::XMLFromSet(2, "5,4,2;11");
xml += NeuralNet::XMLFromSet(0, "3,2;5,1");
xml += NeuralNet::XMLFromSet(1, "4,2;6,2");
xml += NeuralNet::XMLFromSet(2, "6,3;9,3");
NeuralNet::closeXML(xml);
cout << xml << endl;
net.train(xml, NeuralNet::str);
vector<double> v;
@ -36,13 +37,9 @@ int main() {
cin >> tmp;
v.push_back(tmp);
cout << "Third number to add: ";
cin >> tmp;
v.push_back(tmp);
net.setInput(v);
net.propagate();
cout << "Output: " << net.getOutput() << endl;
cout << "Output: " << net.getOutputs()[0] << "; " << net.getOutputs()[1] << endl;
return 0;
}

View file

@ -38,7 +38,7 @@ int main() {
net.setInput(v);
net.propagate();
cout << "Neural net output: " << net.getOutput() << endl;
cout << "Neural net output: " << net.getOutputs()[0] << "; " << net.getOutputs()[1] << endl;
return 0;
}

View file

@ -13,7 +13,7 @@ using namespace std;
using namespace neuralpp;
int main() {
NeuralNet net(2, 2, 1, 0.005, 1000);
NeuralNet net(2, 2, 2, 0.005, 1000);
cout << "Training in progress - This may take a while...\n";
net.train("adder.xml", NeuralNet::file);