Open christianechevarria opened 5 years ago
Interesting idea: a "quick and dirty" way to pinpoint what is causing the bug could be to iteratively restrict the mutation methods to discover if some subset of mutation methods is the culprit
Update:
Wrote a test that calls Network.mutate(methods.mutation.ADD_NODE)
on a network with no hidden neurons and it reliably shows that output neurons are being converted into hidden
Exploring a fix now, will update with more discoveries
Another thing that the tests show is that when neurons are added they're being added to the end of the neurons array which is not in and of itself a bad thing, but I know there are a couple spots where we assume the order of the neurons will be indicative of whether they are inputs, hidden, or outputs so this can also be causing issues.
Description
As the code currently stands, Network relies on two sets
input_nodes
andoutput_nodes
to keep track of inputs and outputs respectively and make decisions on how to operate on Networks.It's imperative that we have a way to detect what neurons are actually inputs and neurons to properly mutate, merge, activate, and otherwise do anything with our architecture-free Networks. This is possibly a long-standing bug that can be contributing to https://github.com/liquidcarrot/carrot/issues/51
This bug was (re)discovered when @teh-mICON reported he was getting un-normalized output like @dan-ryan did before
This is the output from
Network.toJSON
showing the structure of the neurons and connections of @teh-mICON 's network:If you look closely the output_nodes shows that # 9 is an output node, but in one of the connections you can also see that # 9 is a "from" neuron to neuron # 11 which is then the true output
This situation may have come about because of a mutation that added a connection from 9 to 11, something that should not have happened by default which then in turn caused this bug, but even still we should be adaptive enough to update our output node indexes whenever we add connections to former output neurons
Below you'll find a visualization of the network
Screenshots
Files
test/units/architecture/network.1.test.js
src/methods/mutation.js
src/architecture/Network.js
To Reproduce
Build a network, evolve it with
methods.mutation.FFW
as allowed methods, keep checking the output until it falls outside of the expected rangeTasks
mutateOutput
flag also applies to adding connections to output neurons