Simple max(a, b) test-net without iterations

main
mandlm 2015-10-22 16:03:10 +02:00
parent f22e4221a1
commit d4a22ecae7
1 changed files with 14 additions and 17 deletions

View File

@ -1,5 +1,6 @@
#include <iostream> #include <iostream>
#include <exception> #include <exception>
#include <algorithm>
#include "Net.h" #include "Net.h"
@ -9,31 +10,27 @@ int main()
{ {
std::cout << "Neuro running" << std::endl; std::cout << "Neuro running" << std::endl;
Net myNet({ 3, 2, 1 }); Net myNet({ 2, 3, 1 });
for (int i = 0; i < 100000; ++i) std::vector<double> inputValues =
{ {
std::vector<double> inputValues = 0.1,
{ 0.7,
std::rand() / (double)RAND_MAX, };
std::rand() / (double)RAND_MAX,
std::rand() / (double)RAND_MAX
};
std::vector<double> targetValues = { inputValues[2] }; std::vector<double> targetValues = { 0.7 };
myNet.feedForward(inputValues); myNet.feedForward(inputValues);
std::vector<double> outputValues = myNet.getOutput(); std::vector<double> outputValues = myNet.getOutput();
double error = outputValues[0] - targetValues[0]; double error = outputValues[0] - targetValues[0];
std::cout << "Error: "; std::cout << "Error: ";
std::cout << std::abs(error); std::cout << std::abs(error);
std::cout << std::endl; std::cout << std::endl;
myNet.backProp(targetValues); myNet.backProp(targetValues);
}
} }
catch (std::exception &ex) catch (std::exception &ex)
{ {