private int LearnNextImage(int CurrentItem, double[] errors) { int nbofvalidelements = 0; TeacherFile tf = new TeacherFile(); tf.SetFeatureNumber(NBOFFEATURES); double[] CurrentFeatures = new double[NBOFFEATURES]; Boolean[] UsedFeatures = new Boolean[NBOFFEATURES]; UsedFeatures[0] = tf.GetUsedFeatures_RComponent(); UsedFeatures[1] = tf.GetUsedFeatures_GComponent(); UsedFeatures[2] = tf.GetUsedFeatures_BComponent(); UsedFeatures[3] = tf.GetUsedFeatures_Grayscale(); UsedFeatures[4] = tf.GetUsedFeatures_Area(); UsedFeatures[5] = tf.GetUsedFeatures_MinDiameter(); UsedFeatures[6] = tf.GetUsedFeatures_MaxDiameter(); UsedFeatures[7] = tf.GetUsedfeatures_Aspectratio(); UsedFeatures[8] = tf.GetUsedfeatures_Circularity(); double[] Decisions = new double[nbOfUnits_3]; string filename = tf.GetFileName(CurrentItem + 1); int nbofteachers = tf.GetNumberOfTeachers(filename); if (nbofteachers == 0) { return(nbofvalidelements); } int decision = 0; int errorindex = 0; for (int ii = 0; ii < nbofteachers; ii++) { int ExpectedDecision = tf.RetrieveTeacherFeatures(filename, ii + 1, CurrentFeatures, 3, NBOFFEATURES); if (ExpectedDecision == -1) { continue; } for (int jj = 0; jj < NBOFFEATURES; jj++) { if (UsedFeatures[jj] == false) { CurrentFeatures[jj] = 0.0; // (discard the extracted value) } } decision = CImageProcessingUtils.TeachNeuralNetwork(CurrentFeatures, Weights, nbOfUnits_1, nbOfUnits_2, nbOfUnits_3, factor, ExpectedDecision, Decisions); Decisions[ExpectedDecision - 1] -= 1.0; // this element of 'Decisions' vector is the correct answer for (int jj = 0; jj < nbOfUnits_3; jj++) { errors[errorindex] = Decisions[jj]; nbofvalidelements++; errorindex++; } } return(nbofvalidelements); }
private void InitializeWeights() { // init. the weights CImageProcessingUtils.InitNeuralNetwork(Weights, nbOfUnits_1, nbOfUnits_2, nbOfUnits_3); }