-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mutate() function not working as expected #139
Comments
i have the same problem ! have you found the solution?? |
I assume you realise The options that are available for FFW are: mutation.ADD_NODE,
mutation.SUB_NODE,
mutation.ADD_CONN,
mutation.SUB_CONN,
mutation.MOD_WEIGHT,
mutation.MOD_BIAS,
mutation.MOD_ACTIVATION,
mutation.SWAP_NODES You should be using: const neuralNetwork = new neataptic.architect.Random(12,20,2);
const method = neataptic.methods.mutation.FFW.ADD_NODE; // I suggest you make this stochastic
neuralNetwork.mutate(method); TLDR; You're passing an array of objects, the I hope this helps, I've used this library quite a bit and If you find yourself stuck again, have a look through the source; It is generally very simple throughout 👍 |
yes thanks, I understood what you are saying. But when i test
This error it's return But when So ,I think I'm using it badly ^^ |
That error is only thrown if the method passed is undefined. Also, here const method = Methods.mutation.MOD_WEIGHT; I would open the mutation methods file and take a look at the structure of the object etc. it'll help you understand how to effectively use it. |
hoo , yeah it seems to work ! Thanks very much. |
@AZE38 No worries 👍 |
arf , weight dont change, juste no error message "-_- i think ,im just a fu***** noob |
@AZE38 You may be better off starting a Stack Overflow post for this. But in order for anyone to help you here, we need a MCVE (https://stackoverflow.com/help/mcve) example of what it is you're doing. |
i just create some network , i evaluate and selection and duplicate for newpop, and i want just change Weight of my newpop. Like this : so i just want do network[i].mutate(Methods.mutation.MOD_WEIGHT) But just if i create One Network like this the weight dont change i initialize like So i have all methods etc, but dont change weight. |
@AZE38 Without the code you're actually using it is extremely difficult for anyone to help debug. In those examples you just gave you are using You should have something along the lines of: let population = [];
for (let i = 0; i < 100; i++) {
population.push(new Network(2,6));
}
// ...
// Now let's mutate
let newPopulation = [];
for (let i = 0; i < population.length; i++) {
let agent = population[i]; // this is our Network instance
agent.mutate(methods.mutation.MOD_WEIGHT);
newPopulation.push(agent);
}
// At this point, all agents should have mutated weights |
yes it's exactly what i am doing. Hoo.. May be it's the "percentRate" of the number of mutate weights wich is small , and many node dont mutate !? i can fix the "PercentRate"? |
@AZE38 I'm sorry but I do not understand what you mean. It'd be far easier if you provide the actual code it is you're using. Are you expecting ALL weights to have changed? If that is the case, you're misunderstanding how this works. Only 1 stochastic connection will be mutated. If you want to mutate the weight for every connection, you will need to do this manually. Here is the original source code for the MOD_WEIGHT case: var allconnections = this.connections.concat(this.selfconns);
var connection = allconnections[Math.floor(Math.random() * allconnections.length)];
var modification = Math.random() * (method.max - method.min) + method.min;
connection.weight += modification; As you can see, it'll only update a single connection. |
" Are you expecting ALL weights to have changed?" No no , just a portion of them , but how i can fix this "ratio". Ho, ok , when i use Network.mutate(methods.mutation.MOD_WEIGHT), i modifie just ONE weight of them !? if i want mutate ~30% of my network's weights, i put Network.mutate in loop to repeat the network.mutate()? |
First answer, yes, only one weight is modified. Second answer, that wouldn't necessarily mutate 30% of your weights. You would mutate 30 times, but not necessarily 30 different weights. |
ok ok ok ! Thanks very much, it's work now ^^ |
Heres my code:
The two neural nets being console logged are identical - there was no mutation going on whatsoever. After doing some troubleshooting of my own (yes, the library is linked to the program), I am completely stuck. Why isn't the mutate() method working as intended on my neural network? Thanks in advance!
The text was updated successfully, but these errors were encountered: