private void CopyLayerSizes(NeuralNetworkCompact deepCopyBlueprint) { for (int i = 0; i < layerSizes.Length; i++) { layerSizes[i] = deepCopyBlueprint.layerSizes[i]; } }
public NeuralNetworkCompact(NeuralNetworkCompact deepCopyBlueprint) { mutationChance = deepCopyBlueprint.mutationChance; maxFlatMutation = deepCopyBlueprint.maxFlatMutation; layerSizes = new int[deepCopyBlueprint.layerSizes.Length]; CopyLayerSizes(deepCopyBlueprint); neurons = new float[layerSizes.Length][]; weights = new float[layerSizes.Length][][]; InitNeurons(); CopyWeights(deepCopyBlueprint); }
private void CopyWeights(NeuralNetworkCompact deepCopyBlueprint) { for (int layerIndex = 1; layerIndex < layerSizes.Length; layerIndex++) { weights[layerIndex] = new float[layerSizes[layerIndex]][]; for (int neuronIndex = 0; neuronIndex < layerSizes[layerIndex]; neuronIndex++) { weights[layerIndex][neuronIndex] = new float[layerSizes[layerIndex - 1]]; for (int weightIndex = 0; weightIndex < layerSizes[layerIndex - 1]; weightIndex++) { weights[layerIndex][neuronIndex][weightIndex] = deepCopyBlueprint.weights[layerIndex][neuronIndex][weightIndex]; } } } }