diff --git a/.gitignore b/.gitignore index b0c914a..5efa0bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ __pycache__ *.html .venv neuralWeights.json -neuralWeights.json.bak +neuralWeights.json.* .imgLinkCache.json diff --git a/caliGraph.py b/caliGraph.py index 97cde1f..be0892a 100755 --- a/caliGraph.py +++ b/caliGraph.py @@ -435,8 +435,9 @@ def scoreUnread(G, globMu, globStd): score = 0 nb = dict(neuralBins) act = {} + jig = {} for b in nb: - act[b] = sum(nb[b])/len(nb[b]) + act[b], jig[b] = norm.fit(nb[b]) score += act[b] * getWeightForType(b) score /= sum([abs(getWeightForType(b)) for b in nb]) node['score'] = math.tanh(score/10)*10 @@ -1200,7 +1201,7 @@ def findNewBooks(G, books, mu, num=-1, minRecSco=5): # while batchSize is implemented, we only get a good gonvergence when we disable it (batchSize=-1) # but might be necessary to enable later for a larger libary for better training performance... # maybe try again for 128 books? -def evaluateFitness(books, batchSize=16, debugPrint=False, runPagerank=True): +def evaluateFitness(books, batchSize=16, debugPrint=False, calcPagerank=True): global weights G = buildBookGraph(books) graphAddAuthors(G, books) @@ -1208,7 +1209,7 @@ def evaluateFitness(books, batchSize=16, debugPrint=False, runPagerank=True): graphAddTopLists(G, books) graphAddSeries(G, books) graphAddTags(G, books) - if runPagerank: + if calcPagerank: runPagerank(G) ratedBooks = [n for n in list(G.nodes) if 'rating' in G.nodes[n] and G.nodes[n]['rating'] != None] @@ -1259,7 +1260,7 @@ def train(initGamma, full=True, noPagerank=False): gamma = initGamma books = loadBooksFromDB() bestWeights = copy.copy(weights) - mse, gradient = evaluateFitness(books, runPagerank=not noPagerank) + mse, gradient = evaluateFitness(books, calcPagerank=not noPagerank) delta = math.sqrt(sum(gradient[g]**2 for g in gradient)/len(gradient)) best_mse = mse stagLen = 0 @@ -1277,7 +1278,7 @@ def train(initGamma, full=True, noPagerank=False): weights[wt] += gamma*gradient[wt]/math.sqrt(delta) #else: # del weights[wt] - mse, gradient = evaluateFitness(books, runPagerank=not noPagerank) + mse, gradient = evaluateFitness(books, calcPagerank=not noPagerank) if mse < last_mse: gamma = gamma*1.25 else: