コード例 #1
0
 public void Mutate(ref GaussianGenerator rnd, float learningRate)
 {
     foreach (Layer layer in model.layers)
     {
         for (int iWeight = 0; iWeight < layer.weights.Length; iWeight++)
         {
             layer.weights[iWeight] += rnd.NextFloat1() * learningRate;
         }
     }
     PrepareCache();
 }
コード例 #2
0
    public void GaussianTest()
    {
        Random            _rndu = new Random((uint)UnityEngine.Random.Range(0, int.MaxValue));
        GaussianGenerator _rndn = new GaussianGenerator(_rndu);

        for (int iCnt = 0; iCnt < 100; iCnt++)
        {
            float val = _rndn.NextFloat1();
            Debug.Log(val);
            Debug.Assert(!float.IsNaN(val));
        }
    }
コード例 #3
0
 public float[] MutateExisting(IReadOnlyCollection <float> parent)
 {
     float[] result = parent.ToArray();
     Mutate(result, () => _learnRate * _rndg.NextFloat1());
     return(result);
 }