Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -70,9 +70,9 @@ class GeneticAlgorithm:
|
|
70 |
parent1_weights = parent1.get_weights()
|
71 |
parent2_weights = parent2.get_weights()
|
72 |
# Average the weights of the two parents
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
self.population += offspring
|
77 |
|
78 |
def mutation(self):
|
|
|
70 |
parent1_weights = parent1.get_weights()
|
71 |
parent2_weights = parent2.get_weights()
|
72 |
# Average the weights of the two parents
|
73 |
+
child_weights = [(np.array(w1) + np.array(w2)) / 2 for w1, w2 in zip(parent1_weights, parent2_weights)]
|
74 |
+
child.set_weights(child_weights)
|
75 |
+
offspring.append(child)
|
76 |
self.population += offspring
|
77 |
|
78 |
def mutation(self):
|