From 9ec78acd88a915923b08be7c44b7dffbca71c984 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 28 Aug 2020 22:28:34 +0200 Subject: [PATCH] Tweaked cost function --- rgbAI/lib/func.py | 2 +- rgbAI/main.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rgbAI/lib/func.py b/rgbAI/lib/func.py index f079756..85231d7 100644 --- a/rgbAI/lib/func.py +++ b/rgbAI/lib/func.py @@ -16,7 +16,7 @@ class AIlib: for i in range(outLen): sumC += (out[i] - correctOut[i])**2 # get the difference of every value - return sumC / outLen # return the average cost of all rows + return sumC # return the average cost of all rows def genRandomMatrix( x:int, y:int, min: float=0.0, max: float=1.0 ): # generate a matrix with x, y dimensions with random values from min-max in it return np.random.rand(x, y) diff --git a/rgbAI/main.py b/rgbAI/main.py index f20e33a..652ad7d 100755 --- a/rgbAI/main.py +++ b/rgbAI/main.py @@ -22,8 +22,8 @@ class rgb(object): def calcError( self, inp:np.array, out:np.array ): cost = ai.calcCost( inp, out ) - print(cost) # Cost needs to get to 0, we can figure out this with backpropagation + return cost def learn(): print("learn") @@ -49,4 +49,6 @@ def init(): # init cost = bot.calcError(inpArr, res) + print("Cost: " + str(cost)) + init()