Ejemplo n.º 1
0
        /// <summary>
        /// Opens the .ann file at the given location.
        /// </summary>
        /// <param name="path">The .ann file path.</param>
        /// <returns>The opened ANN (artifical neural network) file.</returns>
        public static AnnFile Open(string path)
        {
            var parts = path.Split('\\');

            path = Path.HasExtension(path) ? Path.ChangeExtension(path, "ann") : $"{path}.ann";
            path = parts.Count() != 1 ? path : Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), path);

            AnnFile annFile;

            using (StreamReader reader = new StreamReader(path))
            {
                annFile = new AnnFile
                {
                    Name            = Regex.Replace(parts.Last(), @"\..*", ""),
                    Activation      = ReadActivationFunction(reader),
                    InputNeurons    = ReadUIntArray(reader),
                    OutputNeurons   = ReadUIntArray(reader),
                    AdjacencyMatrix = ReadAdjacencyMatrix(reader)
                };
            }

            return(annFile);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs a new instance of the <see cref="NeuralNetwork"/> class.
 /// </summary>
 /// <param name="annFile">The .ann file.</param>
 public NeuralNetwork(AnnFile annFile)
     : this(annFile.AdjacencyMatrix, annFile.InputNeurons, annFile.OutputNeurons, annFile.Activation)
 {
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new instance of the <see cref="NeuralNetwork"/> class.
 /// </summary>
 /// <param name="path">The .ann file path.</param>
 public NeuralNetwork(string path)
     : this(AnnFile.Open(path))
 {
 }