Dont train if we are already perfect
This commit is contained in:
parent
9f9d2390b3
commit
1303f302d3
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user