mirror of
https://github.com/BlackLight/neuralpp.git
synced 2024-11-16 06:47:16 +01:00
45 lines
766 B
C++
45 lines
766 B
C++
/**
|
|
* This source makes sums between two numbers using pre-trained neural network
|
|
* saved on "adder.net"
|
|
*
|
|
* by BlackLight, 2009
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <neural++.hpp>
|
|
|
|
using namespace std;
|
|
using namespace neuralpp;
|
|
|
|
#define NETFILE "adder.net"
|
|
|
|
int main() {
|
|
double a,b;
|
|
NeuralNet net;
|
|
|
|
try {
|
|
net = NeuralNet(NETFILE);
|
|
}
|
|
|
|
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;
|
|
|
|
vector<double> v;
|
|
v.push_back(a);
|
|
v.push_back(b);
|
|
|
|
net.setInput(v);
|
|
net.propagate();
|
|
cout << "Neural net output: " << net.getOutputs()[0] << "; " << net.getOutputs()[1] << endl;
|
|
|
|
return 0;
|
|
}
|
|
|