aforge.net神经网络保存

using System;
using System.Collections.Generic;
using System.Text;
 
using AForge.Neuro;
using AForge.Neuro.Learning;
 
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
 
namespace khiNeuralNet
{
    /// <summary>
    /// Allows saving and loading of the AForge Neural Network
    /// </summary>
    public class NeuralNetIO
    {
        // Protect the class from instantiation
        private NeuralNetIO() { }
 
        /// <summary>
        /// Save the network
        /// </summary>
        /// <param name="Net">The network to save</param>
        public static void SaveNet(ActivationNetwork Net, string FilePath)
        {
            FileStream fs = new FileStream(FilePath, FileMode.Create); 
            BinaryFormatter formatter = new BinaryFormatter(); 
            formatter.Serialize(fs, Net); 
            fs.Close();
        }
        
        /// <summary>
        /// Load a network
        /// </summary>
        /// <param name="FilePath">The path to the binary network file</param>
        /// <returns></returns>
        public static ActivationNetwork LoadNet(string FilePath)
        {
            FileStream fs = new FileStream(FilePath, FileMode.Open);
            BinaryFormatter formatter = new BinaryFormatter();  
            ActivationNetwork net = (ActivationNetwork)formatter.Deserialize(fs); 
            fs.Close();
            return net;
        }
 
    }
 
}

aforge.net神经网络保存,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。