/// <summary> /// Fill all layers weights by desired configuration /// </summary> /// <param name="weightsFillInfo">Weights configuration</param> /// <param name="randomSeed">Seed of random that generate weights values</param> public void FillWeights(WeightsFillInfo weightsFillInfo, int randomSeed) { //Instance initializated? CheckInstance(); for (int l = 0; l < LayersCount; l++) { var layer = this[l]; for (int i = 0; i < layer.NeuronsCount; i++) { //Fill weights by native function int seed = (randomSeed + i) * l; Native.FloatArrayRandomFill(layer.Weights[i], layer.NeuronsWeightsSize, weightsFillInfo.CoefficientOfWeights, weightsFillInfo.NegativeWeights, seed, ThreadingMode.SingleThread); } } }
/// <summary> /// Initializate neural network with initialization all weights by desired configuration /// </summary> /// <param name="layersCfg">Layers configuration</param> /// <param name="weightsFillInfo">Weights configuration</param> /// <param name="randomSeed">Seed of random that generate weights values</param> public NeuralNetwork(LayerCfg[] layersCfg, WeightsFillInfo weightsFillInfo, int randomSeed) : this(layersCfg) { this.FillWeights(weightsFillInfo, randomSeed); }