public Support_Vector_Machine(ReadImages RM) { for (int g = 0; g < 5; ++g) { mm[g] = new List <Point>(); } this.Clases = RM.classes; this.DAtaset = RM; trainData = new Matrix <float>(RM.TrainingSamples.Count, RM.TrainingSamples[0].Feature.Descriptor.Length); trainClasses = new Matrix <float>(RM.TrainingSamples.Count, 1); sample = new Matrix <float>(1, RM.TrainingSamples[0].Feature.Descriptor.Length); string[] all_classes = RM.classes.ToArray(); /// make function to load training data set for (int u = 0; u < RM.TrainingSamples.Count; u++) { for (int p2 = 0; p2 < RM.TrainingSamples[0].Feature.Descriptor.Length; ++p2) { trainData[u, p2] = RM.TrainingSamples[u].Feature.Descriptor[p2]; } trainClasses[u, 0] = Map(RM.TrainingSamples[u].Lable[0]) + 1; } model = new SVM(); p = new SVMParams(); p.KernelType = Emgu.CV.ML.MlEnum.SVM_KERNEL_TYPE.LINEAR; p.SVMType = Emgu.CV.ML.MlEnum.SVM_TYPE.C_SVC; p.C = 1; p.TermCrit = new MCvTermCriteria(100, 0.00001); //bool trained = model.Train(trainData, trainClasses, null, null, p); bool trained = model.TrainAuto(trainData, trainClasses, null, null, p.MCvSVMParams, 5); }
public MultiLayerPerceptron(ReadImages RI, double Eta, int NumberOfEpochs, int NumberOfHiddenLayers, int[] NumberOfNeuronsForEachHiddenLayer) { for (int g = 0; g < 5; ++g) { mm[g] = new List <Point>(); } this.NumberOfEpochs = NumberOfEpochs; this.NumberOfHiddenLayers = NumberOfHiddenLayers; this.NumberOfNeuronsForEachHiddenLayer = NumberOfNeuronsForEachHiddenLayer; this.AllLayers = new Layer[NumberOfHiddenLayers + 2]; this.Dataset = RI; AllLayers[0] = new Layer(Dataset.TrainingSamples[0].Feature.Descriptor.Count(), Eta, Dataset.TrainingSamples[0].Feature.Descriptor.Count()); for (int i = 1; i <= this.NumberOfHiddenLayers; ++i) { AllLayers[i] = new Layer(NumberOfNeuronsForEachHiddenLayer[i - 1], Eta, AllLayers[i - 1].NumberOfNeurons); } AllLayers[this.NumberOfHiddenLayers + 1] = new Layer(Dataset.classes.Count(), Eta, NumberOfNeuronsForEachHiddenLayer[NumberOfNeuronsForEachHiddenLayer.Length - 1]); }
public SVM_handler(ReadImages RM2, DataGridView confusion_matrix_control, TextBox overall_accuracy_control, Label trainingtime, Label testingtime, Label l1, Label L2) { RI = RM2; confusion_matrix = new int[1, this.RI.classes.Count]; for (int f = 0; f < 1; f++) { for (int x = 0; x < this.RI.classes.Count; x++) { confusion_matrix[f, x] = 0; } } this.confusion_matrix_control = confusion_matrix_control; this.trainingtime = trainingtime; this.testingtime = testingtime; this.overall_accuracy_control = overall_accuracy_control; Label1 = l1; label2 = L2; Process currentProcess = System.Diagnostics.Process.GetCurrentProcess(); long totalBytesOfMemoryUsed = currentProcess.WorkingSet64; Benchmark.Start(); S_V_M = new Support_Vector_Machine(RI); Benchmark.End(); this.trainingtime.Text = " The Training Time : " + Benchmark.GetSeconds().ToString(); Process currentProcess1 = System.Diagnostics.Process.GetCurrentProcess(); long totalBytesOfMemoryUsed1 = currentProcess1.WorkingSet64; Label1.Text = "The Training Memmory is " + Math.Abs(totalBytesOfMemoryUsed - totalBytesOfMemoryUsed1) + " bytes"; for (int d = 0; d < this.RI.TestingImages.Length; ++d) { LM = new loadimage(RI.TestingImages[d]); Voting(LM.LM, S_V_M.testing(LM), confusion_matrix, this.LM.classes); } display_results(this.confusion_matrix_control, this.overall_accuracy_control); MessageBox.Show("Done Testing"); }
public Task_3_View_handler(ReadImages RM) { this.ReadIm = RM; }
public SVM_View(ReadImages RM) { InitializeComponent(); SH = new SVM_handler(RM, this.dataGridView_confusion_matrix, this.textBox_overall_accuracy, this.Trainingtime, this.Testing_time, label1, label2); }
public Neual_network_form(ReadImages RM) { NN = new Task_3_View_handler(RM); InitializeComponent(); }