src/main/components/network/models/MoNeuron.java
// randomly adds an amount to each weight
randomly adds an amount to each weight
randomly adds an amount to each weight
public void mutateWeights() {
        if (this.weights != null) {
            for (int i = 0; i < weights.length; i++) {
                double chance = MoFunctions.getRandom(1.0,0.0);
                if (chance >= 0.5) {
                    float randomMutation = MoFunctions.getRandom(0.02f,-0.02f);
                    if (Math.abs(weights[i] + randomMutation) <= 1) {
                        weights[i] += randomMutation;
                    } else {
                        weights[i] -= randomMutation;
                    }
                    break;
                }
            }
        }
    }
public void mutateWeights ( ) { if ( this . weights != null ) { for ( int i = 0 ; i < weights . length ; i ++ ) { double chance = MoFunctions . getRandom ( 1.0 , 0.0 ) ; if ( chance >= 0.5 ) { float randomMutation = MoFunctions . getRandom ( 0.02f , - 0.02f ) ; if ( Math . abs ( weights [ i ] + randomMutation ) <= 1 ) { weights [ i ] += randomMutation ; } else { weights [ i ] -= randomMutation ; } break ; } } } }
randomly adds an amount to each weight
randomly adds an amount to each weight