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(); }
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)); } }
public float[] MutateExisting(IReadOnlyCollection <float> parent) { float[] result = parent.ToArray(); Mutate(result, () => _learnRate * _rndg.NextFloat1()); return(result); }