public static void SaveNetwork(string path, ref NeuronalNetwork neuronalNetwork) { FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, neuronalNetwork); fs.Close(); }
public TrainerAnn(ref NeuronalNetwork neuronalNetwork, ReadFile rf, bool serialize) { _neuronalNetwork = neuronalNetwork; if (serialize == false) { _neuronalNetwork.InitializeNetwork(); } //initializa training data _trainSet = rf.GetTrainingData(); _testData = rf.GetTestData(); File.WriteAllText("pua.txt", string.Empty); }
private void button3_Click(object sender, EventArgs e) { //train network listBox1.Items.Add("Training begin...\n"); //the network was not loaded, is new, so we need to train _neuronalNetwork = new NeuronalNetwork(540, 10, 4); _trainAnn = new TrainerAnn(ref _neuronalNetwork, _readFile, false); _trainAnn.DoTrain(5000); listBox1.Items.Add("Training complete...\n"); //_trainAnn.TestRun(3000); //listBox1.Text += "Testing data complete...\n"; }
private void button2_Click(object sender, EventArgs e) { //load neuronal network from file using (var fileDialog = new OpenFileDialog()) { fileDialog.Title = "Please select a file"; fileDialog.Multiselect = false; fileDialog.Filter = "NET|*.net"; DialogResult dr = fileDialog.ShowDialog(); if (dr == DialogResult.OK) { string fileName = Path.GetFileName(fileDialog.FileName); _neuronalNetwork = Serializer.LoadNetwork(fileName); _trainAnn = new TrainerAnn(ref _neuronalNetwork, _readFile, true); listBox1.Items.Add("Load Network complete...\n"); button5.Enabled = true; // dam enable la butonul de save } } }