float -> double for everything, learning rate now always considered >= 0

This commit is contained in:
blacklight 2009-08-08 18:05:02 +02:00
parent 1f65c8a26b
commit 1aa4ec7646
9 changed files with 110 additions and 110 deletions

Binary file not shown.

View file

@ -10,9 +10,9 @@
using namespace neuralpp;
int main() {
NeuralNet *net = new NeuralNet(2, 2, 1, -0.005, 10000);
NeuralNet net(2, 2, 1, 0.005, 10000);
string xml;
float tmp;
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
@ -22,8 +22,8 @@ int main() {
xml += NeuralNet::XMLFromSet(2, "5,4;9");
NeuralNet::closeXML(xml);
net->train(xml, NeuralNet::str);
vector<float> v;
net.train(xml, NeuralNet::str);
vector<double> v;
cout << "Network status: trained\n\n";
cout << "First number to add: ";
@ -34,9 +34,9 @@ int main() {
cin >> tmp;
v.push_back(tmp);
net->setInput(v);
net->propagate();
cout << "Output: " << net->getOutput() << endl;
net.setInput(v);
net.propagate();
cout << "Output: " << net.getOutput() << endl;
return 0;
}

View file

@ -12,11 +12,11 @@ using namespace neuralpp;
#define NETFILE "adder.net"
int main() {
float a,b;
NeuralNet *net = NULL;
double a,b;
NeuralNet net;
try {
net = new NeuralNet(NETFILE);
net = NeuralNet(NETFILE);
}
catch (NetworkFileNotFoundException e) {
@ -30,13 +30,13 @@ int main() {
cout << "Second number to add: ";
cin >> b;
vector<float> v;
vector<double> v;
v.push_back(a);
v.push_back(b);
net->setInput(v);
net->propagate();
cout << "Neural net output: " << net->getOutput() << endl;
net.setInput(v);
net.propagate();
cout << "Neural net output: " << net.getOutput() << endl;
return 0;
}

View file

@ -11,12 +11,12 @@
using namespace neuralpp;
int main() {
NeuralNet *net = new NeuralNet (2, 2, 1, -0.005, 10000);
NeuralNet net(2, 2, 1, 0.005, 10000);
cout << "Training in progress - This may take a while...if it gets stuck, interrupt and restart the app\n";
net->train("adder.xml", NeuralNet::file);
net.train("adder.xml", NeuralNet::file);
net->save("adder.net");
net.save("adder.net");
cout << "Network trained. You can use adder.net file now to load this network\n";
return 0;
}