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()
|
books = loadBooksFromDB()
|
||||||
bestWeights = copy.copy(weights)
|
bestWeights = copy.copy(weights)
|
||||||
mse, gradient = evaluateFitness(books)
|
mse, gradient = evaluateFitness(books)
|
||||||
|
delta = sum(gradient[g]**2 for g in gradient)
|
||||||
best_mse = mse
|
best_mse = mse
|
||||||
delta = 1
|
|
||||||
stagLen = 0
|
stagLen = 0
|
||||||
|
|
||||||
while gamma > 1.0e-06 and delta > 1.0e-06:
|
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:
|
if stagLen == 3 or mse > 100:
|
||||||
for wt in weights:
|
for wt in weights:
|
||||||
weights[wt] = random.random()
|
weights[wt] = random.random()
|
||||||
|
print('Done.')
|
||||||
|
|
||||||
def saveWeights(weights):
|
def saveWeights(weights):
|
||||||
with open('neuralWeights.json', 'w') as f:
|
with open('neuralWeights.json', 'w') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user