/// <summary> /// Loads a neural network from a .ann file. /// </summary> /// <param name="path">The .ann file path.</param> /// <returns>The neural network.</returns> public NeuralNetwork LoadNeuralNetwork(string path) { var annFile = AnnFile.Open(path); var network = LoadNeuralNetwork(annFile); return(network); }
public void AnnFileInputOutputTest() { var path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); _annFile.WriteToDisk(path); var annFile = AnnFile.Open(Path.Combine(path, _name)); Assert.AreEqual(_annFile.Name, annFile.Name, "Failed to read .ann file name"); Assert.AreEqual(_annFile.Activation, annFile.Activation, "Failed to read .ann file activation function."); for (var i = 0; i < annFile.InputNeurons.Count; i++) { Assert.AreEqual(_annFile.InputNeurons[i], annFile.InputNeurons[i], "Failed to read .ann file input neurons."); } for (var i = 0; i < annFile.OutputNeurons.Count; i++) { Assert.AreEqual(_annFile.OutputNeurons[i], annFile.OutputNeurons[i], "Failed to read .ann file output neurons."); } var n = annFile.AdjacencyMatrix.GetLength(0); var m = annFile.AdjacencyMatrix.GetLength(1); for (var i = 0; i < n; i++) { for (var j = 0; j < m; j++) { Assert.AreEqual(_annFile.AdjacencyMatrix[i, j], annFile.AdjacencyMatrix[i, j], "Failed to read .ann file adjacency matrix."); } } }