From 1303f302d3a8add4c6654b516385e607c65544df Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 26 Sep 2021 23:17:03 +0200 Subject: [PATCH] Dont train if we are already perfect --- caliGraph.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/caliGraph.py b/caliGraph.py index ebef49b..dc4b5a7 100755 --- a/caliGraph.py +++ b/caliGraph.py @@ -831,8 +831,8 @@ def train(gamma = 1, full=True): books = loadBooksFromDB() bestWeights = copy.copy(weights) mse, gradient = evaluateFitness(books) + delta = sum(gradient[g]**2 for g in gradient) best_mse = mse - delta = 1 stagLen = 0 while gamma > 1.0e-06 and delta > 1.0e-06: @@ -854,6 +854,7 @@ def train(gamma = 1, full=True): if stagLen == 3 or mse > 100: for wt in weights: weights[wt] = random.random() + print('Done.') def saveWeights(weights): with open('neuralWeights.json', 'w') as f: