public static int[] ClusterWithFuzzyART(double[,] trainingData, out int noOfCommittedF2Nodes) { int trnSetSize = trainingData.GetLength(0); int IPSize = trainingData.GetLength(1); int F2Size = trnSetSize; int maxIterations = 100; LoggedConsole.WriteLine("trnSetSize=" + trnSetSize + " IPSize=" + IPSize + " F2Size=" + F2Size); //************************** INITIALISE PARAMETER VALUES ************************* double alpha = 0.57; //increasing alpha proliferates categories - 0.57 is good value double beta = 0.8; //Beta=1.0 for fast learning/no momentum. Beta=0.0 for no change in weights double rho = 0.9; //vigilance parameter - increasing rho proliferates categories double theta = 0.1; //threshold for contrast enhancing - values < threshold := 0.0 int seed = 12345; //to seed random number generator FuzzyART fuzzyART = new FuzzyART(IPSize, F2Size); //initialise FuzzyART class fuzzyART.SetParameterValues(alpha, beta, rho, theta); fuzzyART.WriteParameters(); fuzzyART.InitialiseArrays(); //fuzzyART.RepeatTrainNet(trainingData, maxIterations, 1, seed, 3); //noOfCommittedF2Nodes = fuzzyART.CountCommittedF2Nodes(); var output = fuzzyART.TrainNet(trainingData, maxIterations, seed); int iterNum = output.Item1; noOfCommittedF2Nodes = output.Item2; LoggedConsole.WriteLine("Training iterations=" + iterNum + ". Categories=" + noOfCommittedF2Nodes); return(fuzzyART.inputCategory); //keepScore; } //END of ClusterShapesWithFuzzyART.
} //END of ClusterShapesWithFuzzyART. public static int[] RepeatClusterWithFuzzyART(double[,] trainingData, out int committedNodeCount) { if (trainingData == null) { LoggedConsole.WriteLine("WARNING: ClusterWithFuzzyART() PASSED NULL TRAINING DATA!"); committedNodeCount = 0; return(null); } int trnSetSize = trainingData.GetLength(0); int IPSize = trainingData.GetLength(1); int F2Size = trnSetSize; int numberOfRepeats = 1; int maxIterations = 100; LoggedConsole.WriteLine("trnSetSize=" + trnSetSize + " IPSize=" + IPSize + " F2Size=" + F2Size); int[] noOfCommittedF2 = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{# committed F2 units} //int[] iterToConv = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{# training iterations} int code = 0; //used for getting error messages //************************** INITIALISE PARAMETER VALUES ************************* //double alpha = 0.2; //increasing alpha proliferates categories - 0.57 is good value //double beta = 0.5; //beta=1 for fast learning/no momentum. beta=0 for no change in weights //double rho = 0.9; //vigilance parameter - increasing rho proliferates categories //double theta = 0.05; //threshold for contrast enhancing //double alpha = 0.2; //increasing alpha proliferates categories - 0.57 is good value //double beta = 0.1; //beta=1 for fast learning/no momentum. beta=0 for no change in weights //double rho = 0.9; //vigilance parameter - increasing rho proliferates categories //double theta = 0.0; //threshold for contrast enhancing double alpha = 0.2; //increasing alpha proliferates categories - 0.57 is good value double beta = 0.2; //beta=1 for fast learning/no momentum. beta=0 for no change in weights double rho = 0.8; //vigilance parameter - increasing rho proliferates categories double theta = 0.0; //threshold for contrast enhancing FuzzyART fuzzyART = new FuzzyART(IPSize, F2Size); //initialise FuzzyART class fuzzyART.SetParameterValues(alpha, beta, rho, theta); fuzzyART.WriteParameters(); //{********** DO REPEATS ***********} for (int rep = 0; rep < numberOfRepeats; rep++) { //{********* RUN NET for ONE SET OF PARAMETERS for ALL ITERATIONS *********} fuzzyART.InitialiseArrays(); int seed = 12345 * (rep + 1); fuzzyART.TrainNet(trainingData, maxIterations, seed); if (code != 0) { break; } noOfCommittedF2[rep] = fuzzyART.CountCommittedF2Nodes(); //ScoreTrainingResults (noOfCommittedF2[rep], noClasses, F2classLabel, F2classProb); //wtsFpath = ART.ARTDir + ART.wtsFname + "s" + simul + rep + ART.wtsFExt; //art2a.WriteWts(wtsFpath, F2classLabel, F2classProb); //if (ART.DEBUG) LoggedConsole.WriteLine("wts= " + wtsFpath + " train set= " + trnSetFpath); LoggedConsole.WriteLine("Number Of Committed F2 Nodes after rep" + rep + " = " + noOfCommittedF2[rep]); } //end; {for rep = 1 to norepeats do} {***** END OF REPEATS *****} committedNodeCount = noOfCommittedF2[0]; int[] keepScore = fuzzyART.inputCategory; return(keepScore); } //END of RepeatClusterWithFuzzyART.