From 80013cab71f9beea543e1111694275b917ef4073 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Sat, 5 Sep 2020 23:42:04 +0200 Subject: [PATCH] Gradient calculation --- rgbAI/lib/func.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rgbAI/lib/func.py b/rgbAI/lib/func.py index 38ee221..e3329be 100644 --- a/rgbAI/lib/func.py +++ b/rgbAI/lib/func.py @@ -53,12 +53,12 @@ class AIlib: def gradient( dCost:float, prop:list ): propLen = len(prop) - #print("PropLEN: ", propLen) - #print(prop) - #print("\n") gradient = [None] * propLen - for i in range( propLen ): - gradient[i] = dCost / prop[i] + for i in range( propLen, 0, -1 ): + if( i == propLen ): + gradient[i] = dCost / prop[i] + else: + gradient[i] = dCost / (prop[i] + gradient[i+1]) return gradient