update: small genetic improvements

This commit is contained in:
KOSMOGOR
2025-04-11 11:13:19 +03:00
parent 766e6fb7e2
commit 90f8c08796
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ class GeneticAlgorithm:
def mutate(self, model: NeuralNetwork):
for param in model.parameters():
if torch.rand(1).item() < self.mutationRate:
param.data += torch.randn_like(param.data) * 0.1 * (1 if torch.rand(1).item() >= 0.5 else -1)
param.data += torch.randn_like(param.data) * 0.1
return model
def learn(self, fitness: list):