Exemplo n.º 1
0
        /// <summary> Calculates and returns the highest number of <see cref="Neurons.Neuron"/>s in the given <paramref name="neuralNetwork"/>'s <see cref="neuronLayers"/>. </summary>
        /// <param name="neuralNetwork"> The <see cref="NeuralNetwork"/> whose <see cref="NeuronLayer"/>s to calculate from. </param>
        /// <returns> The highest number of <see cref="Neurons.Neuron"/>s in the given <paramref name="neuralNetwork"/>'s <see cref="neuronLayers"/>. </returns>
        private static int calculateHighestNeuronCount(IReadOnlyNeuralNetwork neuralNetwork)
        {
            int highestNeuronCount = 0;

            for (int l = 0; l < neuralNetwork.NeuronLayerCount; l++)
            {
                if (neuralNetwork.GetNeuronLayer(l).Count > highestNeuronCount)
                {
                    highestNeuronCount = neuralNetwork.GetNeuronLayer(l).Count;
                }
            }

            return(highestNeuronCount);
        }
Exemplo n.º 2
0
        /// <summary> Creates a new <see cref="NetworkChange"/> for the given <paramref name="neuralNetwork"/>. </summary>
        /// <param name="neuralNetwork"> The <see cref="IReadOnlyNeuralNetwork"/> whose changes are being stored. </param>
        public NetworkChange(IReadOnlyNeuralNetwork neuralNetwork)
        {
            // Set the neural network.
            NeuralNetwork = neuralNetwork;

            // Initialise the neuron and weight changes.
            neuronLayerChanges = new NeuronLayerChange[neuralNetwork.NeuronLayerCount - 1];
            weightLayerChanges = new WeightLayerChange[neuralNetwork.WeightLayerCount];
            for (int i = 0; i < neuronLayerChanges.Length; i++)
            {
                neuronLayerChanges[i] = new NeuronLayerChange(neuralNetwork.GetNeuronLayer(i + 1));
            }
            for (int i = 0; i < weightLayerChanges.Length; i++)
            {
                weightLayerChanges[i] = new WeightLayerChange(neuralNetwork.GetWeightLayer(i));
            }
        }