static void Main_(string[] args) { BrainCore bc = new BrainCore(3, 9, 2); bc.SaveToFile("", "1"); bc.StreachLayer(1, 2, 3); bc.SaveToFile("", "2"); }
/// <summary> /// Uses existing brain to create new one. /// </summary> /// <param name="baseBrain">Brain to be copied.</param> public BrainCore(BrainCore baseBrain) { biases = baseBrain.biases; synapses = baseBrain.synapses; layerCounts = baseBrain.layerCounts; int[] hiddenNeurons = new int[layerCounts.Length - 2]; for (int i = 0; i < hiddenNeurons.Length;) { hiddenNeurons[i] = layerCounts[++i]; } SetupLayerCounts(layerCounts[0], hiddenNeurons, layerCounts[layerCounts.Length - 1]); activeNeurons = new Matrix <double> [neuronLayerCount]; neuronActivation = baseBrain.neuronActivation; }
public BrainCore(BrainCore baseBrain, int fromLayer, int layerCount) { if (fromLayer + layerCount > baseBrain.layerCounts.Length) { throw new ArgumentOutOfRangeException(); } if (fromLayer < 0 || layerCount < 1) { throw new ArgumentOutOfRangeException(); } biases = PiwotToolsLib.Data.Arrays.BuildSubArray(baseBrain.biases, fromLayer, layerCount); synapses = PiwotToolsLib.Data.Arrays.BuildSubArray(baseBrain.synapses, fromLayer, layerCount); layerCounts = PiwotToolsLib.Data.Arrays.BuildSubArray(baseBrain.layerCounts, fromLayer, layerCount); int[] hiddenNeurons = new int[layerCounts.Length - 2]; for (int i = 0; i < hiddenNeurons.Length;) { hiddenNeurons[i] = layerCounts[++i]; } SetupLayerCounts(layerCounts[0], hiddenNeurons, layerCounts[layerCounts.Length - 1]); activeNeurons = new Matrix <double> [neuronLayerCount]; neuronActivation = baseBrain.neuronActivation; }
/// <summary> /// Uses already existing brain to build this instance of OpenBrain. /// </summary> /// <param name="brainCore">Brain to be used as a base.</param> public OpenBrain(BrainCore brainCore) : base(brainCore) { BuildOpenBrain(); }