wagenaartje / neataptic

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

Infinity/NaN output #130

Open dan-ryan opened 6 years ago

dan-ryan commented 6 years ago

I'm getting Infinity/NaN outputs while training. I'm using Nodejs 9.9.0 with strict mode on.

My 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,
        }
    );

Infinity Example:

The normalised data: [0.9354838709677419, 0.5, 0.5933786078098472, 0.5880669161907702]

The genome:

{"nodes":[{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":0},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":1},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":2},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":3},{"bias":1.1508084667830487,"type":"output","squash":"SELU","mask":1,"index":4}],"connections":[{"weight":1,"from":4,"to":4,"gater":4},{"weight":-0.05001360658035439,"from":3,"to":4,"gater":null},{"weight":0.9984137443904727,"from":2,"to":4,"gater":null},{"weight":-0.7832753538521565,"from":1,"to":4,"gater":null},{"weight":-0.9040067054346645,"from":0,"to":4,"gater":4}],"input":4,"output":1,"dropout":0}

NaN Example:

The normalised data: [0.3870967741935484, 0.75, 0.5040295048190726, 0.5575469079452833]

The genome:

{"nodes":[{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":0},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":1},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":2},{"bias":0,"type":"input","squash":"LOGISTIC","mask":1,"index":3},{"bias":-0.0717463180924848,"type":"hidden","squash":"BENT_IDENTITY","mask":1,"index":4},{"bias":-0.02994106373052867,"type":"output","squash":"LOGISTIC","mask":1,"index":5}],"connections":[{"weight":1,"from":4,"to":4,"gater":null},{"weight":1,"from":5,"to":5,"gater":null},{"weight":-0.048341462482942354,"from":4,"to":5,"gater":null},{"weight":-0.4890970041600281,"from":3,"to":5,"gater":5},{"weight":0.9984137443904727,"from":2,"to":5,"gater":5},{"weight":-0.4890970041600281,"from":3,"to":4,"gater":4},{"weight":0.024574079733371557,"from":1,"to":5,"gater":null},{"weight":0.9984137443904727,"from":2,"to":4,"gater":4},{"weight":-0.9040067054346645,"from":0,"to":5,"gater":5},{"weight":0.049181674792330154,"from":1,"to":4,"gater":null},{"weight":0.04742932010695605,"from":0,"to":4,"gater":null}],"input":4,"output":1,"dropout":0}