internal void LoadTeachingSet(string fileName) { TeachingSet tset = NeuralNetworks.TeachingSet.FromFile(fileName); if (tset == null || tset.Count == 0) { throw new ApplicationException("The file does not contain any data."); } _teachingSetFileName = fileName; _teachingSet = tset; _normalizedTeachingSet = new TeachingSet(tset); _normalizedTeachingSet.Normalize(); _examinedNetwork = new LinearNetwork(tset.InputCount, tset.OutputCount); InitializeTeaching(); }
internal void LoadTeachingSet(string fileName) { TeachingSet tset = NeuralNetworks.TeachingSet.FromFile(fileName); if (tset == null || tset.Count == 0) { throw new ApplicationException("The file does not contain any data."); } if (tset.OutputCount != 1) { throw new ApplicationException( "The file you supplied describe a learning set for the " + "multi-neuron network. This application is capable of " + "learning only one neuron. Please select a file that " + "contains a learning set for one neuron."); } _teachingSetFileName = fileName; _teachingSet = tset; _examinedNeuron = new Neuron(tset.InputCount); InitializeTeaching(); }
private void UseCustomTeachingSet() { if (uiOpenFile.ShowDialog(this) == DialogResult.OK) { string fname = uiOpenFile.FileName; try { TeachingSet tset = TeachingSet.FromFile(fname); if (tset.Count == 0) { MessageBox.Show(this, "The file contains no usable data.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); uiStandardSet.Checked = true; return; } if (tset.InputCount != 2 || tset.OutputCount != 1) { MessageBox.Show(this, "The file should be made for a 2-input, 1-output network.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); uiStandardSet.Checked = true; return; } _teachingSet = tset; ShowTeachingSet(); RestartTeaching(); } catch (Exception ex) { MessageBox.Show(this, "Could not open the selected file.\n\nDetails: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); uiStandardSet.Checked = true; } } }
private void UseStandardTeachingSet() { /* We divide by 2, because each teaching set part takes half * of the gap size as its offset. */ double offset = GetGapSize(uiGapSize.Value) / 2.0; _teachingSet = new TeachingSet(2, 1); TeachingSet.Element elem = new TeachingSet.Element(); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { // Careful! We shouldn't make anything 0; it will render // the element unuseful. elem.Inputs = new double[] { 0.2 + x * 0.2 + offset, -0.3 + y * 0.2 }; elem.ExpectedOutputs = new double[] { 1.0 }; _teachingSet.Add(elem); elem.Inputs = new double[] { -0.2 - x * 0.2 - offset, -0.3 + y * 0.2 }; elem.ExpectedOutputs = new double[] { -1.0 }; _teachingSet.Add(elem); } } elem.Inputs = new double[] { offset, 0.3 }; elem.ExpectedOutputs = new double[] { 1.0 }; _teachingSet.Add(elem); elem.Inputs = new double[] { -offset, 0.3 }; elem.ExpectedOutputs = new double[] { -1.0 }; _teachingSet.Add(elem); ShowTeachingSet(); RestartTeaching(); }