From d4a22ecae7746bc58dade6f55d788bf1a233bdbb Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Thu, 22 Oct 2015 16:03:10 +0200 Subject: [PATCH] Simple max(a, b) test-net without iterations --- Neuro.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Neuro.cpp b/Neuro.cpp index 513e4f0..7f57d99 100644 --- a/Neuro.cpp +++ b/Neuro.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "Net.h" @@ -9,31 +10,27 @@ int main() { 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 inputValues = { - std::vector inputValues = - { - std::rand() / (double)RAND_MAX, - std::rand() / (double)RAND_MAX, - std::rand() / (double)RAND_MAX - }; + 0.1, + 0.7, + }; - std::vector targetValues = { inputValues[2] }; + std::vector targetValues = { 0.7 }; - myNet.feedForward(inputValues); + myNet.feedForward(inputValues); - std::vector outputValues = myNet.getOutput(); + std::vector outputValues = myNet.getOutput(); - double error = outputValues[0] - targetValues[0]; + double error = outputValues[0] - targetValues[0]; - std::cout << "Error: "; - std::cout << std::abs(error); - std::cout << std::endl; + std::cout << "Error: "; + std::cout << std::abs(error); + std::cout << std::endl; - myNet.backProp(targetValues); - } + myNet.backProp(targetValues); } catch (std::exception &ex) {