码迷,mamicode.com
首页 > Web开发 > 详细

aforge.net神经网络保存

时间:2014-08-14 19:26:49      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:des   os   io   for   ar   cti   new   .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神经网络保存,布布扣,bubuko.com

aforge.net神经网络保存

标签:des   os   io   for   ar   cti   new   .net   

原文地址:http://www.cnblogs.com/villa/p/3912755.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!