示例#1
0
        public void Save(string path, NeuralNet nn)
        {
            FileStream    outFile   = File.OpenWrite(path);
            XmlSerializer formatter = new XmlSerializer(nn.GetType());

            formatter.Serialize(outFile, nn);
        }
示例#2
0
        public NeuralNet Load(string file)
        {
            NeuralNet     ret       = new NeuralNet();
            XmlSerializer formatter = new XmlSerializer(ret.GetType());
            FileStream    nFile     = new FileStream(file, FileMode.Open);

            byte[] buffer = new byte[nFile.Length];
            nFile.Read(buffer, 0, (int)nFile.Length);
            MemoryStream stream = new MemoryStream(buffer);

            return((NeuralNet)formatter.Deserialize(stream));
        }