wagenaartje / neataptic

:rocket: Blazing fast neuro-evolution & backpropagation for the browser and Node.js
https://wagenaartje.github.io/neataptic/
Other
1.18k stars 278 forks source link

Using "maxNodes" crashes with "No (correct) mutate method given" #128

Open dan-ryan opened 6 years ago

dan-ryan commented 6 years ago

When using maxNodes or maxConnsit crashes my app. I'm using version 1.4.7.

(node:13872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 109) (node:13872) UnhandledPromiseRejectionWarning: Error: No (correct) mutate method given! at Network.mutate (D:\Git\App\App\node_modules\neataptic\src\architecture\network.js:273:13) at Neat.mutate (D:\Git\App\App\node_modules\neataptic\src\neat.js:167:30) at Neat.evolve (D:\Git\App\App\node_modules\neataptic\src\neat.js:110:10) at endEvaluation (D:\Git\App\App\app.js:304:10) at learnData (D:\Git\App\App\app.js:213:9) at axios.get.then.response (D:\Git\App\App\app.js:153:5) at at process._tickCallback (internal/process/next_tick.js:118:7) (node:13872) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 110)

Looking at the codebase, it looks like selectMutationMethod can return undefined and therefore can be passed into the mutate method which crashes.

Looks like the original pull request (https://github.com/wagenaartje/neataptic/pull/62/files) used to return nulls.

dan-ryan commented 6 years ago

I've created PR #129. Seems to no longer crash.

dan-ryan commented 6 years ago

How is maxNodes/maxConns/ etc meant to work? I'm still going over the maximum number I set in Neat and therefore it's overfitting.

My current settings:

    Methods.mutation.MOD_ACTIVATION.mutateOutput = false;
    Methods.mutation.MOD_ACTIVATION.allowed = [

        Methods.activation.LOGISTIC,
        Methods.activation.TANH,
        Methods.activation.STEP,
        Methods.activation.SOFTSIGN,
        Methods.activation.SINUSOID,
        Methods.activation.GAUSSIAN,
        Methods.activation.BIPOLAR,
        Methods.activation.BIPOLAR_SIGMOID,
        Methods.activation.HARD_TANH,
        Methods.activation.INVERSE,

        Methods.activation.SELU,
        Methods.activation.RELU,

        Methods.activation.BENT_IDENTITY,
        Methods.activation.IDENTITY,
        //Methods.activation.ABSOLUTE
    ];

    neat = new Neat(4, 1, null,
        {
            mutation: Methods.mutation.ALL,
            popsize: 100,
            mutationRate: 0.2,
            elitism: 10,
            //clear: true, 
            equal: true,
            network: new Architect.Random(4, 5, 1),
            provenance: 2,
            maxNodes: 7, 
            maxConns: 10,
            maxGates: 5,
        }
    );
dan-ryan commented 6 years ago

Hey @alaa-eddine I saw you originally did the pull request for this feature. Since this project is now unmaintained, I'm hoping maybe you could see why the max settings are not working?

christianechevarria commented 5 years ago

Hi @dan-ryan just wanted to let you know that we're maintaining a spin-off of Neataptic, just noted this issue and incorporated your changes. We would love to add you as a contributor and give you credit:

https://github.com/liquidcarrot/carrot

hope to see you there! 👍

dan-ryan commented 5 years ago

@christianechevarria Oh nice. After all these years there hasn't been another replacement for Neataptic so good to see. I've been learning TensorFlow.js which is fast, powerful, not user-friendly and no neuroevolution. There is ml5js built on top of Tensorflow.js which is user-friendly but limited with no neuroevolution (but maybe in the future).

dan-ryan commented 5 years ago

My pull request still didn't fix the issue that the network was going over maxNodes and maxConns. So someone should look at that.

Do you have a changelog for the differences from Neatapic to the latest version of Carrot?