3
我有一個關於如何在encog庫c#中保存神經網絡的問題。我想要序列化來自輸入和輸出層的隱藏層和數據的權重。如果我想要成功地反序列化它,也需要保存網絡的某個地方結構。 在創建網絡和序列化BasicNetwork對象的代碼部分下面,當然這是不正確的。我發現了很多關於如何使用java版本的信息,但注意到了c#。保存encog網絡c#
BasicNetwork network = CreateNet(nettype,res11[i],1,2);
INeuralDataSet trainingSet = new BasicNeuralDataSet(masStudyInput, masStudyOutput);
INeuralDataSet TestingSet = new BasicNeuralDataSet(masTestInput, mastestOutput);
ITrain train = new ResilientPropagation(network, trainingSet);
int epoch = 1;
//network.Structure.Layers.
MessageBox.Show("Start");
do
{
train.Iteration();
mist = GetMistake(ref network, ref TestingSet);
chart1.Invoke((Action)(() =>
{
chart1.Series[0].Points.AddY(train.Error);
chart1.Series[1].Points.AddY(mist);
}));
network.
if (mist < 0.8)
{
string XMLfilename = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\" + mist + ".xml";
System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(BasicNetwork));
TextWriter writerr = new StreamWriter(XMLfilename);
writer.Serialize(writerr, network);
writerr.Close();
}
epoch++;
}
while ((epoch < 1000));SS