Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Dann mutateRandom

Matias Vazquez-Levi edited this page Feb 1, 2021 · 4 revisions

Back to Dann

mutateRandom( range , probability );

This function mutates each weights randomly. This is for Neuroevolution tasks.

  • range

    This will multiply with a random number from -range to range and add to each weight.

  • probability

    The probability of a weight being affected by a random mutation. Ranging from 0 to 1. Setting this value to 1 would mutate all the model's weights.

Example

const nn = new Dann(4,2);
nn.makeWeights();

nn.log({weights:true,table:true})

// adding (weight*random(-0.1,0.1)) to 50% of the weights.
nn.mutateRandom(0.1,0.5);

nn.log({weights:true,table:true})