Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
6518f83
1
Parent(s):
264634b
Save best tree during training
Browse files
eureqa.jl
CHANGED
@@ -469,12 +469,23 @@ function run(
|
|
469 |
)::Population
|
470 |
|
471 |
allT = LinRange(1.0f0, 0.0f0, ncycles)
|
|
|
|
|
472 |
for iT in 1:size(allT)[1]
|
473 |
if annealing
|
474 |
pop = regEvolCycle(pop, allT[iT], annealing=true)
|
475 |
else
|
476 |
pop = regEvolCycle(pop, 1.0f0, annealing=true)
|
477 |
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
if verbosity > 0 && (iT % verbosity == 0)
|
479 |
bestPops = bestSubPop(pop)
|
480 |
bestCurScoreIdx = argmin([bestPops.members[member].score for member=1:bestPops.n])
|
@@ -482,6 +493,11 @@ function run(
|
|
482 |
debug(verbosity, bestCurScore, " is the score for ", stringTree(bestPops.members[bestCurScoreIdx].tree))
|
483 |
end
|
484 |
end
|
|
|
|
|
|
|
|
|
|
|
485 |
return pop
|
486 |
end
|
487 |
|
|
|
469 |
)::Population
|
470 |
|
471 |
allT = LinRange(1.0f0, 0.0f0, ncycles)
|
472 |
+
bestScore = Inf32
|
473 |
+
bestTree = Node(1f0)
|
474 |
for iT in 1:size(allT)[1]
|
475 |
if annealing
|
476 |
pop = regEvolCycle(pop, allT[iT], annealing=true)
|
477 |
else
|
478 |
pop = regEvolCycle(pop, 1.0f0, annealing=true)
|
479 |
end
|
480 |
+
|
481 |
+
# Save current best
|
482 |
+
bestCurScoreIdx = argmin([pop.members[member].score for member=1:pop.n])
|
483 |
+
bestCurScore = pop.members[bestCurScoreIdx].score
|
484 |
+
if bestCurScore < bestScore
|
485 |
+
bestScore = bestCurScore
|
486 |
+
bestTree = copyNode(pop.members[bestCurScoreIdx].tree)
|
487 |
+
end
|
488 |
+
|
489 |
if verbosity > 0 && (iT % verbosity == 0)
|
490 |
bestPops = bestSubPop(pop)
|
491 |
bestCurScoreIdx = argmin([bestPops.members[member].score for member=1:bestPops.n])
|
|
|
493 |
debug(verbosity, bestCurScore, " is the score for ", stringTree(bestPops.members[bestCurScoreIdx].tree))
|
494 |
end
|
495 |
end
|
496 |
+
|
497 |
+
# TODO - make this the oldest member instead of 1
|
498 |
+
pop.members[1].tree = bestTree
|
499 |
+
pop.members[1].score = bestScore
|
500 |
+
|
501 |
return pop
|
502 |
end
|
503 |
|