/// <summary> Creates, loads, and returns a <see cref="NeuralNetwork"/> using the given <paramref name="networkLoader"/>. </summary> /// <param name="networkLoader"> The <see cref="INetworkLoader"/> used to load the network. </param> /// <returns> The loaded <see cref="NeuralNetwork"/>. </returns> public static NeuralNetwork Load(INetworkLoader networkLoader) { // Get the number of neuron layers in the file. int neuronLayerCount = networkLoader.GetNetworkNeuronLayerCount(); // Create an empty neural network. NeuralNetwork neuralNetwork = new NeuralNetwork(networkLoader.GetNetworkLearningRate(), neuronLayerCount); // Create the neuron layers for the neural network. for (uint i = 0; i < neuronLayerCount; i++) { neuralNetwork.neuronLayers[i] = NeuronLayer.Load(neuralNetwork, networkLoader, i); } // Create the weight layers for the neural network. for (uint i = 0; i < neuronLayerCount - 1; i++) { neuralNetwork.weightLayers[i] = WeightLayer.Load(neuralNetwork, networkLoader, i, neuralNetwork.neuronLayers[i], neuralNetwork.neuronLayers[i + 1]); } // Set the highest neuron count. neuralNetwork.HighestNeuronCount = calculateHighestNeuronCount(neuralNetwork); // Return the neural network. return(neuralNetwork); }