Adding crossover function#100
Open
enginefeeder101 wants to merge 4 commits intoCodingTrain:masterfrom
Open
Conversation
This commit adds crossover functions to the Matrix and NeuralNetwork class. It defaults to a uniform crossover (ratio = 0.5), but this is customizable (third parameter). You can use it as such: ```javascript let mom = new NeuralNetwork(2, 4, 1); let dad = new NeuralNetwork(2, 4, 1); let child = NeuralNetwork.crossover(mom, dad); ```
Member
|
Awesome job! The use of Note for examples I prefer to use something generic like I will hold off on merging but will do so during a video when I implement the algorithm! I think this is simple enough that I don't need to do my own video tutorial implementing crossover. (I cover it in the GA series anyway.) |
There was a semicolon missing after the `map()` function.
This commit adds a check to the `crossover()` functions (both Matrix and NeuralNetwork) that does not allow to crossover between different breeds. In other words, only if two NeuralNetwork have the same number of nodes thay can crossover. Otherwise undefined is returned. Same for the Matrix crossover function.
Contributor
Author
|
I added a commit which checks if a NeuralNetwork and/or Matrix are of the same breed before applying the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds crossover functions to the Matrix and NeuralNetwork class. It defaults
to a uniform crossover (ratio = 0.5), but this is customizable (third parameter).
You can use it as such: