public void Save(string path, NeuralNet nn) { FileStream outFile = File.OpenWrite(path); XmlSerializer formatter = new XmlSerializer(nn.GetType()); formatter.Serialize(outFile, nn); }
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)); }