2009-02-18 00:19:29 +01:00
|
|
|
/**
|
|
|
|
* This source makes sums between two numbers using pre-trained neural network
|
|
|
|
* saved on "adder.net"
|
|
|
|
*
|
|
|
|
* by BlackLight, 2009
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
2009-08-07 15:55:59 +02:00
|
|
|
#include <neural++.hpp>
|
2009-02-18 00:19:29 +01:00
|
|
|
using namespace neuralpp;
|
|
|
|
|
|
|
|
#define NETFILE "adder.net"
|
|
|
|
|
|
|
|
int main() {
|
2009-08-08 18:05:02 +02:00
|
|
|
double a,b;
|
|
|
|
NeuralNet net;
|
2009-02-18 00:19:29 +01:00
|
|
|
|
|
|
|
try {
|
2009-08-08 18:05:02 +02:00
|
|
|
net = NeuralNet(NETFILE);
|
2009-02-18 00:19:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
catch (NetworkFileNotFoundException e) {
|
|
|
|
cerr << "Fatal error while opening " << NETFILE << ": " << e.what();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << "First number to add: ";
|
|
|
|
cin >> a;
|
|
|
|
|
|
|
|
cout << "Second number to add: ";
|
|
|
|
cin >> b;
|
|
|
|
|
2009-08-08 18:05:02 +02:00
|
|
|
vector<double> v;
|
2009-02-18 00:19:29 +01:00
|
|
|
v.push_back(a);
|
|
|
|
v.push_back(b);
|
|
|
|
|
2009-08-08 18:05:02 +02:00
|
|
|
net.setInput(v);
|
|
|
|
net.propagate();
|
|
|
|
cout << "Neural net output: " << net.getOutput() << endl;
|
2009-02-18 00:19:29 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|