首页 > 代码库 > aforge.net神经网络保存
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; } } }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。