You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Example/MLKit/GeneticOperations.swift
+78-2Lines changed: 78 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,24 @@
8
8
9
9
import Foundation
10
10
import MachineLearningKit
11
+
import Upsurge
11
12
13
+
14
+
/// The GeneticOperations class manages encoding genes into weights for the neural network and decoding neural network weights into genes. These methods are not provided in the framework itself, rather it was for the game example.
12
15
finalclassGeneticOperations{
13
16
17
+
18
+
/**
19
+
The encode method converts a NueralNet object to an array of floats by taking the weights of each layer and placing them into an array.
@@ -33,4 +49,64 @@ final class GeneticOperations {
33
49
return genotypeRepresentation
34
50
}
35
51
52
+
53
+
/**
54
+
The decode method converts a genotype back to a NeuralNet object by taking each value from the genotype and mapping them to a neuron in a particular layer.
0 commit comments