smashing 'deees bugs
This commit is contained in:
parent
9a02bdc2a8
commit
cbb884b377
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,5 +2,5 @@ __pycache__
|
|||||||
*.html
|
*.html
|
||||||
.venv
|
.venv
|
||||||
neuralWeights.json
|
neuralWeights.json
|
||||||
neuralWeights.json.bak
|
neuralWeights.json.*
|
||||||
.imgLinkCache.json
|
.imgLinkCache.json
|
||||||
|
11
caliGraph.py
11
caliGraph.py
@ -435,8 +435,9 @@ def scoreUnread(G, globMu, globStd):
|
|||||||
score = 0
|
score = 0
|
||||||
nb = dict(neuralBins)
|
nb = dict(neuralBins)
|
||||||
act = {}
|
act = {}
|
||||||
|
jig = {}
|
||||||
for b in nb:
|
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 += act[b] * getWeightForType(b)
|
||||||
score /= sum([abs(getWeightForType(b)) for b in nb])
|
score /= sum([abs(getWeightForType(b)) for b in nb])
|
||||||
node['score'] = math.tanh(score/10)*10
|
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)
|
# 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...
|
# but might be necessary to enable later for a larger libary for better training performance...
|
||||||
# maybe try again for 128 books?
|
# 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
|
global weights
|
||||||
G = buildBookGraph(books)
|
G = buildBookGraph(books)
|
||||||
graphAddAuthors(G, books)
|
graphAddAuthors(G, books)
|
||||||
@ -1208,7 +1209,7 @@ def evaluateFitness(books, batchSize=16, debugPrint=False, runPagerank=True):
|
|||||||
graphAddTopLists(G, books)
|
graphAddTopLists(G, books)
|
||||||
graphAddSeries(G, books)
|
graphAddSeries(G, books)
|
||||||
graphAddTags(G, books)
|
graphAddTags(G, books)
|
||||||
if runPagerank:
|
if calcPagerank:
|
||||||
runPagerank(G)
|
runPagerank(G)
|
||||||
|
|
||||||
ratedBooks = [n for n in list(G.nodes) if 'rating' in G.nodes[n] and G.nodes[n]['rating'] != None]
|
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
|
gamma = initGamma
|
||||||
books = loadBooksFromDB()
|
books = loadBooksFromDB()
|
||||||
bestWeights = copy.copy(weights)
|
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))
|
delta = math.sqrt(sum(gradient[g]**2 for g in gradient)/len(gradient))
|
||||||
best_mse = mse
|
best_mse = mse
|
||||||
stagLen = 0
|
stagLen = 0
|
||||||
@ -1277,7 +1278,7 @@ def train(initGamma, full=True, noPagerank=False):
|
|||||||
weights[wt] += gamma*gradient[wt]/math.sqrt(delta)
|
weights[wt] += gamma*gradient[wt]/math.sqrt(delta)
|
||||||
#else:
|
#else:
|
||||||
# del weights[wt]
|
# del weights[wt]
|
||||||
mse, gradient = evaluateFitness(books, runPagerank=not noPagerank)
|
mse, gradient = evaluateFitness(books, calcPagerank=not noPagerank)
|
||||||
if mse < last_mse:
|
if mse < last_mse:
|
||||||
gamma = gamma*1.25
|
gamma = gamma*1.25
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user