public static int[] ClusterWithART2a(double[,] trainingData) { //DataTools.WriteMinMaxOfFeatures(trainingData); //if (true) Console.ReadLine(); //string paramsFpath = @"C:\etc"; int trnSetSize = trainingData.GetLength(0); int F1Size = trainingData.GetLength(1); int F2Size = trnSetSize; int numberOfRepeats = 1; int maxIterations = 100; LoggedConsole.WriteLine("trnSetSize=" + trnSetSize + " F1Size=" + F1Size + " F2Size=" + F2Size); bool[] uncommittedJ = new bool[F2Size]; // : PtrToArrayOfBool; int[] noOfCommittedF2 = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{# committed F2Neta units} int[] iterToConv = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{for training only} int code = 0; // : word; {used for getting error messages} //{************************** INITIALISE VALUES *************************} //double[,] parameters = ART.ReadParameterValues(paramsFpath); //int simulationsCount = parameters.GetLength(0); //int paramCount = parameters.GetLength(1); int simulationsCount = 1; double alpha = 0.4; //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.99; //vigilance parameter - increasing rho proliferates categories double theta = 0.05; //threshold for contrast enhancing ART_2A art2a = new ART_2A(F1Size, F2Size); //{********** DO SIMULATIONS WITH DIFFERENT PARAMETER VALUES ***********} for (int simul = 0; simul < simulationsCount; simul++) { //pass the eight params for this run of ART2A - alpha, beta, c, d, rho, theta, add1, rhoStar art2a.SetParameterValues(alpha, beta, rho, theta); art2a.WriteParameters(); //art2a.SetParameterValues(parameters[simul, 0], parameters[simul, 1], parameters[simul, 2], parameters[simul, 3],); //Console.ReadLine(); //{********** DO REPEATS ***********} for (int rep = 0; rep < numberOfRepeats; rep++) { //{********* RUN NET for ONE SET OF PARAMETERS for ALL ITERATIONS *********} art2a.InitialiseArrays(); code = 0; art2a.TrainNet(trainingData, maxIterations, simul, rep, code); if (code != 0) { break; } noOfCommittedF2[rep] = art2a.CountCommittedF2Nodes(); //ScoreTrainingResults (noOfCommittedF2[rep], noClasses, F2classLabel, F2classProb); //wtsFpath = ART.ARTDir + ART.wtsFname + "s" + simul + rep + ART.wtsFExt; //art2a.WriteWts(wtsFpath, F2classLabel, F2classProb); //if (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 *****} } //end; {for simul = 1 to noSimulationsInRun do} {**** END OF SIMULATE *****} int[] keepScore = art2a.inputCategory; return keepScore; } //END of ClusterShapes.
} //end; //public static bool ParamValuesOK(int versionID) //{ //var // bool AllOK = true; // File ParamsF; // : text; // double[] parameters = new double[MaxARTparamsNo]; // of real; // int noValues; // : word; // int simul, pn; // : word; // {parameter counter} // char key; // : char; // int i; //:word; // TextBackGround (1); // {blue background} // ClrScr; // LoggedConsole.WriteLine; // LoggedConsole.WriteLine (" CHECKING PARAMETER VALUES for Net version ",ARTversion); // LoggedConsole.WriteLine; // assign (ParamsF, ParamsFPath); // {prepare parameters file} // reset (ParamsF); // readln (ParamsF, NoSimulationsInRun); // for (int simul= 0; simul < noSimulationsInRun; simul++) // { // ReadParameterValues(noValues, ParamsF, parameters); // LoggedConsole.WriteLine (" Line "+simul+ " is OK"); // //if (noValues != MaxARTparamsNo-1 ) // //{ // // for (pn = 1 to maxARTParamsNo-1) // {display all 8 parameter values} // // LoggedConsole.WriteLine (" (",pn,") ",paramNames[versionID, pn]:10," = ",parameters[pn]:7:4); // // LoggedConsole.WriteLine; // // LoggedConsole.WriteLine (" Fault in values for simulation ",simul); // // LoggedConsole.WriteLine (" Must have exactly ",maxARTparamsNo-1, " parameter values."); // // LoggedConsole.WriteLine (" Press any key to return to main menu."); // // key = readkey; // // ParamvaluesOK = false; // // exit; // //} //end; // //{make sure theta is less than 1/sqrM} // //if ((versionID != verFuzzyART)&& (versionID != verfuzzyARTMAP) ) // // if (parameters[Theta] >= (1/Sqrt(F1SizeofNeta)) ) ) // //{ // // parameters[Theta] = (1/Sqrt(F1SizeofNeta) - 0.01); // // //for (pn = 1 to maxARTParamsNo-1) //{display first 7 parameter values} // // //LoggedConsole.WriteLine (" (",pn,") ",paramNames[versionID, pn]:10," = ",parameters[pn]:7:4); // // LoggedConsole.WriteLine; // // LoggedConsole.WriteLine (" Fault in values for simulation " + simul); // // LoggedConsole.WriteLine (" Theta must be < 1/sqrtM ie 1/sqrt(F1size of net a)"); // // LoggedConsole.WriteLine (" Have automatically set theta = 1/sqrtM - 0.01"); // // LoggedConsole.WriteLine (" Press any key to continue."); // // key = readkey; // //} //end; // //{calc sigma and rho*} // if (versionID == verART2a ) // { // Sigma = (Params[c]*ARTParams[d]) / (1-ARTParams[d]); // if (sigma > 1) // { // //for (pn = 1 to maxARTParamsNo-1) //{display first 7 parameter values} // //LoggedConsole.WriteLine (" ("+pn+") "+paramNames[versionID, pn]:10+" = "+parameters[pn]:7:4); // LoggedConsole.WriteLine; // LoggedConsole.WriteLine (" Fault in values for simulation ",simul); // LoggedConsole.WriteLine (" Sigma = cd/1-d > 1.0. Choose proper values for c & d"); // LoggedConsole.WriteLine (" Press any key to continue."); // key = readkey; // ParamvaluesOK = false; // exit; // } //end; // } //end; {if verionsID = verART2a} // } //end; {for simul = 1 to noSimulationsInRun do} // Close (ParamsF); // if (AllOK ) // { // LoggedConsole.WriteLine; write (" ALL OK! Press any key to continue ... "); // key = readkey; // clrscr; // } //end; // ParamvaluesOK = AllOK; //} //end; //{This method finds the class which gained max Score for a given F2 unit //and assigns that class label to the unit. It also calculates a Class //probability Score ie ClassNumber/TotalNumber for each F2unit.} // public static void ScoreTrainingResults (noCommitted, noClasses:word; var classLabel:array of word; var classProb:array of real) // { ////var // uNo, cNo : word; {unit and class counter} // ScoreArray : array[1..maxClassNo] of word; // index, count{dummy var}, maxValue, total : word; //for (uNo = 1 to noCommitted{nodes}) //for all units // { // //{first transfer F2 Scores to Score array. This is to avoid passing // // the zero index in the F2ScoreMatrix to the MaxIndex procedure} // total = 0; // for cNo = 1 to noClasses do // { // total = total + F2ScoreMatrix^[uNo][cNo]; {sum over classes} // ScoreArray[cNo] = F2ScoreMatrix^[uNo, cNo]; // } //end; // {MaxIndex returns class with largest count. Random choice if =max} // MaxIndex (noClasses, ScoreArray, index, count, maxValue); // classLabel[uNo]= index+1; {+1 because array processed as 0 to n-1} // if total = 0 // ) ClassProb[uNo] = 0 // else ClassProb[uNo] = maxValue/total; // classLabel[0] = 0; {zero index will be used to indicate unmatched test sig} ////(*** ////for cNo = 1 to noClasses do write (lst, F2ScoreMatrix^[uNo, cNo]:4); ////LoggedConsole.WriteLine (lst); ////LoggedConsole.WriteLine (lst, " max=",maxValue:3, " lbl=",classLabel[uNo]:3, " prob=",ClassProb[uNo]:4:1); ////***) // } //} //end; {of all units} //} //} //end; ScoreTrainingResults //public static void ScoreTestResults //{ ////var // oneVote : array[0..maxClassNo] of word; // repeatsArray : array[1..MaxRepeatNo] of word; // count:word; //{(! used. Returns # of first place getters in case tied vote} // sigNum, rep, cls :word; {counters} // maxVote, maxValue{(! used}, correctClass :word; //for sigNum = 1 to tstSetSize do {find the winning vote for every signal} // { // for cls= 0 to noClasses do oneVote[cls] = 0; {init OneVote} // {transfer votes from matrix to OneVote array and ) find the maximum} // for rep = 1 to norepeats do inc(oneVote[DecisionMatrix^[sigNum,rep] ]); // maxIndex (noClasses+1, oneVote, maxVote, count, maxValue); // decisionMatrix^[sigNum, 0] = maxVote; {store vote winner in zero index} // } //end; {of all signals} // //{summarise results for classified signals and store the test results // in test Score matrix} // for cls = 0 to noClasses+1 do // for rep = 0 to norepeats do // tstScoreMatrix^[cls,rep] = 0; {initialise test Score matrix} // for sigNum = 1 to tstSetSize do // for rep = 0 to norepeats do // { // correctClass = tstSetTargets^[sigNum]; // if decisionMatrix^[sigNum, rep] = 0 ) // inc (tstScoreMatrix^[ 0, rep]) //{skipped or no match sigs go in row 0} // else // if decisionMatrix^[sigNum, rep] = correctClass ) // { // inc (tstScoreMatrix^[ correctClass, rep]); // inc (tstScoreMatrix^[ noClasses+1, rep]); // } //end; // } //end; // for cls = 0 to noClasses+1 do // { // {first transfer rep Scores from matrix to an array which can be passed // to the moment procedure which returns the statistics.} // for rep = 1 to norepeats do // repeatsArray[rep] = tstScoreMatrix^[cls, rep]; // moment(repeatsArray, norepeats, tstResult^[cls].mean, // tstResult^[cls].sd, // tstResult^[cls].min, // tstResult^[cls].max); // tstResult^[cls].vote = tstScoreMatrix^[cls,0]; {transfer vote counts} // tstResult^[noClasses+1].tot = tstSetSize; // } //end; //} //} //end; ScoreTestResults //public static void WriteDecisionMatrix (var F: text) //{ // //var // sigNum, rep, i : word; {counter} // LoggedConsole.WriteLine(F, "THE DECISION MATRIX"); // write (F, "sig# vote"); // for rep = 1 to norepeats do write(lst, rep:5); // LoggedConsole.WriteLine (F, " target"); // for i = 1 to 100 do write (F,"-"); LoggedConsole.WriteLine(F); {draw horiz line} // for sigNum = 1 to tstSetSize do // { // write (F, sigNum:4,"|"); // for rep = 0 to norepeats do // write (F, decisionMatrix^[sigNum, rep]:5); // LoggedConsole.WriteLine (F, " |", tstSetTargets^[sigNum]:4); // } //end; // LoggedConsole.WriteLine (F); // LoggedConsole.WriteLine (F, formfeed); //} // } //end; WriteDecisionMatrix //public static void writeTestResults (var F:text) //{ ////var // k : word; // cls, rep: word; // size : word; // mean, sd : real; // min, max : word; // LoggedConsole.WriteLine (F, "TEST RESULTS/Score from file: ",ResultsFPath); // printDateAndTime (F); // LoggedConsole.WriteLine (F, "ART VERSION = ",versionNames[versionID]); // write (F, "Training Set file = ",TrnSetFPath); // LoggedConsole.WriteLine (F, " Train set size = ",trnSetSize, " signals"); // LoggedConsole.WriteLine (F, "Train target file = ",TrnTarFPath); // write (F, "Test Set file = ",TstSetFPath); // LoggedConsole.WriteLine (F, " Test set size = ",tstSetSize, " signals"); // LoggedConsole.WriteLine (F, "Test target file = ",TstTarFPath); // LoggedConsole.WriteLine (F, "Weights file = ",wtsFpath); // for k = 1 to MaxARTparamsNo do // write (F, paramNames[versionID, k]:9); // LoggedConsole.WriteLine (F); // for k = 1 to MaxARTparamsNo do write (F, ARTparams[k]:9:4); // LoggedConsole.WriteLine (F); // LoggedConsole.WriteLine (F); // write (F, "rep number "); // for rep = 1 to norepeats do write(F, rep:6); // LoggedConsole.WriteLine (F, " av"); // for k = 1 to 80 do write (F,"-"); LoggedConsole.WriteLine(F); {draw horiz line} // write (F, "categories "); // for rep = 1 to norepeats do write(F, noOfCommittedF2[rep]:6); // moment(noOfCommittedF2, norepeats, mean, sd, min, max); // LoggedConsole.WriteLine (F, mean:6:1,"+/-",sd:3:1); // write (F, "iter to conv"); // for rep = 1 to norepeats do write(F, iterToConv[rep]:6); // moment(iterToConv, norepeats, mean, sd, min, max); // LoggedConsole.WriteLine (F, mean:6:1,"+/-",sd:3:1); // write (F, "# skipped "); // for rep = 1 to norepeats do write(F, SkippedBecauseFull[rep]:6); // LoggedConsole.WriteLine (F); // LoggedConsole.WriteLine (F); // size = tstResult^[noClasses+1].tot; {ie size of the test set or tstSetSize} // LoggedConsole.WriteLine(F, "THE TEST Score MATRIX"); // write (F, "class vote"); // for rep = 1 to norepeats do write(F, rep:6); // LoggedConsole.WriteLine (F); // for k = 1 to 80 do write (F,"-"); LoggedConsole.WriteLine(F); {draw horiz line} // for cls= 0 to noClasses+1 do // { // write (F, cls:6); // for rep = 0 to norepeats do // write (F, tstScoreMatrix^[cls, rep]:6); // if cls = 0 ) LoggedConsole.WriteLine (F, " <- no match") // else // if cls = noClasses+1 ) LoggedConsole.WriteLine (F," <- total correct") // else LoggedConsole.WriteLine (F, " <- num correct in class"); // } //end; {end of all classes} // LoggedConsole.WriteLine (F); ////(**** //// LoggedConsole.WriteLine(lst); //// LoggedConsole.WriteLine(lst,"Rep No:","":12,"No match Classes 1 to ",noClasses," Total"); //// for rep=1 to norepeats do //// { //// write(lst, rep:2,"":9); //// for cls = 0 to noClasses+1 do write (lst, tstScoreMatrix^[cls, rep]:5); //// LoggedConsole.WriteLine(lst); //// } //end; //// LoggedConsole.WriteLine(lst); LoggedConsole.WriteLine(lst); ////****) // LoggedConsole.WriteLine (F,"No match":21, "Classes 1 to ":30, noClasses, "Total":20); // write (F,"totals "); // for cls= 0 to noClasses+1 do write (F, tstResult^[cls].tot:14); // LoggedConsole.WriteLine (F); // write (F, "mean "); // for cls= 0 to noClasses+1 do // write (F, tstResult^[cls].mean:7:1,"(",pc(tstResult^[cls].mean, size):4:1,"%)"); // LoggedConsole.WriteLine (F); // write (F, "std dev "); // for cls= 0 to noClasses+1 do // write (F, tstResult^[cls].sd:7:1, "(",pc(tstResult^[cls].sd, size):4:1,"%)"); // LoggedConsole.WriteLine (F); // write (F, "minimum "); // for cls= 0 to noClasses+1 do write (F, tstResult^[cls].min:14); // LoggedConsole.WriteLine (F); // write (F, "maximum "); // for cls= 0 to noClasses+1 do write (F, tstResult^[cls].max:14); // LoggedConsole.WriteLine (F); // write (F, "VOTE "); // for cls= 0 to noClasses+1 do // write (F, tstResult^[cls].vote:7,"(",pc(tstResult^[cls].vote, size):4:1,"%)"); // LoggedConsole.WriteLine (F); // write (F, formFeed); //} //} //end; writeTestResults (var F:text) //public static void MAINMENU() //{ // //var // int i; // : word; // string FPath; // : PathStr; // char choice, key; // : char; // //dirInfo: searchRec; // Repeat // ReadConfigFile; // //TextBackGround (1); //{blue background} // //ClrScr; // LoggedConsole.WriteLine(); // LoggedConsole.WriteLine (" ART MAIN MENU"); // LoggedConsole.WriteLine (" All setting up to be entered in CONFIG file."); // LoggedConsole.WriteLine(); // LoggedConsole.WriteLine (" C) edit CONFIGURATION file:- ",ConfigFpath); // LoggedConsole.WriteLine (" R) edit PARAMETERS file :- ",ParamsFpath); // LoggedConsole.WriteLine (" P) PRINT configuration file."); // LoggedConsole.WriteLine (" D) Display contents of OUTPUT directory."); // LoggedConsole.WriteLine (" T) Print TEXT file."); // LoggedConsole.WriteLine (" M) Print decision MATRIX."); // LoggedConsole.WriteLine(); // LoggedConsole.WriteLine (" O) OK, continue Esc) HALT program"); // Repeat // Choice = Upcase(readkey); // Until choice in ["O", Esc, "R","C","P","D","M","T"]; // Case choice of // "C":{ // SwapVectors; // Exec("c:\\DOS\\edit.com", ConfigFPath); // SwapVectors; // If DOSError <> 0 ) LoggedConsole.WriteLine ("DOS Error # ",DosError); // ClrScr; // ReadConfigFile; // DisplayConfiguration; // } //end;| // "R":{ // SwapVectors; // Exec("c:\\DOS\\edit.com", ParamsFPath); // SwapVectors; // If DOSError <> 0 ) LoggedConsole.WriteLine ("DOS Error # ",DosError); // ClrScr; // } //end; // "P":if (! printerOn ) Printer(!OnMessage // else PrintTextFile(ConfigFName); // "D":{ // ClrScr; // LoggedConsole.WriteLine ("List of files in the directory :- ", OUTPUTdir); // LoggedConsole.WriteLine; // FindFirst (OUTPUTdir+"/*.*", AnyFile, DirInfo); // i = 0; // while (DosError = 0) do // { // inc (i); // write (DirInfo.name:15); // FindNext (DirInfo); // if (i MOD 5 = 0) ) LoggedConsole.WriteLine; // } //end; // LoggedConsole.WriteLine; // LoggedConsole.WriteLine ("Press <space bar> to return to main menu"); // key = readKey; // } //end; // "T": { // LoggedConsole.WriteLine; // write (" Enter full path name of text file to print -> "); // readln (FPath); // if (! FileExists(FPath) ) // { // LoggedConsole.WriteLine; // write (" File does (! exist!! Press any key ->"); // key = readkey; // end else // if (! printerOn ) Printer(!OnMessage // else printTextFile (FPath); // } //end; // "M":if (! printerOn ) Printer(!OnMessage // else writeDecisionMatrix (lst); // Esc: HALT; //} //end; {case choice of} //Until (choice = "O"{OK}) ; //} //end; MAINMENU //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} //{***********************************************************************************************************************************} // {*** MAIN PROGRAM ***} public static void Main() { Tasks task = Tasks.TRAIN; string wtsFname = "output"; double[,] trainingData = null; int trnSetSize = 0; //int tstSetSize = 0; int F1Size = 0; int F2Size = 0; bool[] uncommittedJ = new bool[F2Size]; // : PtrToArrayOfBool; int[] noOfCommittedF2 = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{# committed F2Neta units} int[] iterToConv = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word;{for training only} //char key = '0'; // : char; int code = 0; // : word; {used for getting error messages} //int Score = 0; // : word; //double[] DataArray = new double[maxDataDim]; //double[,] dataMatrix = new double[maxTrnSetSize, maxDataDim]; //of PdataArray; //int[] keepScore = new int[maxTrnSetSize]; //stores the assigned class for every input signal. Used to test for stabilisation/convergence} //int[] SkippedBecauseFull = new int[numberOfRepeats]; // : array[1..MaxRepeatNo] of word; string wtsFpath = ""; string resultsFPath = ""; // : PathStr; string trnSetFpath = ""; //string trnTarFpath = ""; // : pathStr; string tstSetFpath = ""; //string tstTarFpath = ""; // : pathStr; //bool targetFileExists; // : boolean; //string ARTVersion; // : string[50]; //int VersionID; // : integer; //int[] F2classLabel = new int[maxF2Size]; //: array [0..maxF2Size] of word; //double[] F2classProb = new double[maxF2Size]; // : array [0..maxF2Size] of real; //int KeepScore; // : PKeepScore; //{************************** INITIALISE VALUES *************************} //F2ScoreMatrix = new (); //{used to assign classes to F2 nodes after training} //decisionMatrix = new (); //{matrix: tst sig number x repeats } //tstScoreMatrix = new (); //{matrix: tst sig class x repeats } //tstResult = new (); //{array of record: class x tst Score results} //tstSetTargets = new (); //CONFIGURE AND CHECK PARAMETERS //ReadConfigFile; //code = 0; //CheckConfiguration (code); //if(code == 0) ParamValuesOK(versionID); if (task == Tasks.TRAIN || task == Tasks.TRAINTEST) { trnSetFpath = dataFpath; trainingData = FileTools.ReadDoubles2Matrix(dataFpath); trnSetSize = trainingData.GetLength(0); F1Size = trainingData.GetLength(1); F2Size = trainingData.GetLength(0); } double[,] parameters = ReadParameterValues(paramsFpath); int simulationsCount = parameters.GetLength(0); int paramCount = parameters.GetLength(1); ART_2A art2a = new ART_2A(F1Size, F2Size); if (task == Tasks.TEST) // {load the test file weights} { //Case versionID of // verART2A : ReadWtsART2a (wtsFPath, F1SizeOfNeta, F2SizeOfNeta, F2classLabel, F2classProb, code); // verFuzzyART : ReadWtsFuzzyART (wtsFPath, F1SizeOfNeta, F2SizeOfNeta, F2classLabel, F2classProb, code); // verARTMAP2a : { {ReadWtsARTMAP2a;} } //end; // verFuzzyARTMAP: ReadWtsFuzzyARTMAP(wtsFPath, F2classLabel, F2classProb, code); //} //end; {Case Les.algID of} //ReadWtsART2a (wtsFPath, F1SizeOfNeta, F2SizeOfNeta, F2classLabel, F2classProb, code); } //if (code != 0) //{ // LoggedConsole.WriteLine("WARNING!!!!!!!! ERROR READING WTS FILE."); // LoggedConsole.WriteLine(" F1 & F2 sizes in config file and wts file are NOT equal"); // LoggedConsole.WriteLine(" Press any key to return to main menu"); // key = readkey; // goto TheBeginning; //} //{Initialise screen for graphics display of F2 weight graphs} //InitialiseGraphicsMode; //{********** DO SIMULATIONS WITH DIFFERENT PARAMETER VALUES ***********} for (int simul = 0; simul < simulationsCount; simul++) { //pass the eight params for this run of ART2A //alpha, beta, rho, theta, rhoStar art2a.SetParameterValues(parameters[simul, 0], parameters[simul, 1], parameters[simul, 2], parameters[simul, 3]); //set up file name for simulation test results} resultsFPath = ARTDir + wtsFname + "s" + simul.ToString("D2") + "_results.txt"; //init array to count committed F2 nodes //int[] noOfCommittedF2 = new int[ART.numberOfRepeats]; //initialise decision matrix for processing test data} //int[,] decisionMatrix = new int[tstSetSize,norepeats]; //{matrix: tst sig number x repeats } //{********** DO REPEATS ***********} for (int rep = 0; rep < numberOfRepeats; rep++) { LoggedConsole.WriteLine("RUN=", simul, " rep=", rep); //{********* RUN NET for ONE SET OF PARAMETERS for ALL ITERATIONS *********} if (task == Tasks.TRAIN) { art2a.InitialiseArrays(); code = 0; art2a.TrainNet(trainingData, maxIterations, simul, rep, code); if (code != 0) { break; } noOfCommittedF2[rep] = art2a.CountCommittedF2Nodes(); //ScoreTrainingResults (noOfCommittedF2[rep], noClasses, F2classLabel, F2classProb); wtsFpath = ARTDir + ART.wtsFname + "s" + simul + rep + wtsFExt; //art2a.WriteWts(wtsFpath, F2classLabel, F2classProb); if (DEBUG) { LoggedConsole.WriteLine("wts= " + wtsFpath + " train set= " + trnSetFpath); } } if (task == Tasks.TEST) { //{wts file was loaded above. //art2a.TestNet(testData, simul, rep, code) ; //if (code != 0) goto EndOfSimulations; //if (DEBUG) LoggedConsole.WriteLine("wts= " + wtsFpath + " test set= " + tstSetFpath); } if (task == Tasks.TRAINTEST) { //Case versionID of {initialise the weight arrays} //verART2A : InitWtsART2a; //verFuzzyART : InitWtsFuzzyART; //{ verARTMAP2a : InitWtsARTMAP2a; } //verFuzzyARTMAP: InitWtsFuzzyARTMAP; //} //Case Les.algID of} art2a.InitialiseArrays(); art2a.TrainNet(trainingData, maxIterations, simul, rep, code); if (code != 0) { break; } noOfCommittedF2[rep] = art2a.CountCommittedF2Nodes(); //ScoreTrainingResults (noOfCommittedF2[rep], noClasses, F2classLabel, F2classProb); wtsFpath = ARTDir + ART.wtsFname + "s" + simul + rep + wtsFExt; //Case versionID of //verART2A : WriteWtsART2a (wtsFPath, F1SizeOfNeta, F2SizeOfNeta, F2classLabel, F2classProb); //verFuzzyART : WriteWtsFuzzyART(wtsFPath, F1SizeOfNeta, F2SizeOfNeta,F2classLabel, F2classProb); //verFuzzyARTMAP: WriteWtsFuzzyARTMAP(wtsFPath, F2classLabel, F2classProb); //} //Case Les.algID of} //art2a.WriteWts(wtsFPath, F2classLabel, F2classProb); //art2a.TestNet(testData, simul, rep, code); //if (code != 0) goto EndOfSimulations; if (DEBUG) { LoggedConsole.WriteLine("wts= " + wtsFpath + " test set= " + tstSetFpath + " Press any key"); } } //{************** DISPLAY RECONSTRUCTED SIGNALS **************} //for F2uNo = 1 to F2SizeOfNeta do {Calculate the average signal values} //{ // {for j = 0 to noClasses+1 do write (lst, F2ScoreMatrix^[F2uNo][j]:4); // LoggedConsole.WriteLine (lst);} // Score = F2ScoreMatrix^[F2uNo][noClasses+1]; // for F1uNo = 1 to F1SizeOfNeta do // if Score = 0 ) // avSig^[F2uNo]^[F1uNo] = 0.0 // else avSig^[F2uNo]^[F1uNo] = avSig^[F2uNo]^[F1uNo] /Score; //} //end; //{*********** FinalScreenDisplay ***********} //if (DEBUG)FinalScreenDisplay(F1sizeOfNeta,F2SizeOfNeta,F2ScoreMatrix,avSig^,WtsNeta^); //{ // InitialiseDisplayOfF2Weights (F1sizeOfNeta, noOfCommittedF2[rep]); // for (int F2uNo = 0; F2uNo < noOfCommittedF2[rep]; F2uNo++) // { // DisplayF2WtsAndSig(F2uNo, F1sizeOfNeta, noOfCommittedF2[rep], F2ScoreMatrix[F2uNo,noClasses+1], // avSig[F2uNo], wtsNetA[F2uNo], avSigRange, wtsRange); // } //} //end; {if display on do final display} } //end; {for rep = 1 to norepeats do} {***** END OF REPEATS *****} //ScoreTestResults; //if (printTestResults) writeTestResults(lst); // {write to printer.....} //else //{...else write to file} //{ // assign (resultsF, resultsFPath); // rewrite(resultsF); // writeTestResults (resultsF); // close (resultsF); //} //end; //if (printDecisionMatrix) writeDecisionMatrix(lst); } //end; {for simul = 1 to noSimulationsInRun do} {**** END OF SIMULATE *****} //if (printerOn) PrintTextFile(ConfigFpath); //{LABEL} EndOfSimulations: //close (ParamsF); //CloseGraph; //Case versionID of // verART2A : DisposeART2a; // verFuzzyART : DisposeFuzzyART; //{ verARTMAP2a : DisposeARTMAP2a;} // verFuzzyARTMAP: DisposeFuzzyARTMAP; //} //end; {Case Les.algID of} //GoTo TheBeginning; // {****************** DISPOSE OF HEAP VARIABLES ******************} //for j = 1 to MaxTrnSetSize do dispose (DataMatrix[j]); //dispose (keepScore); //dispose (F2ScoreMatrix); {used to assign classes to F2 nodes} //dispose (decisionMatrix); {matrix: tst sig number x repeats } //dispose (tstScoreMatrix); {matrix: tst sig class x repeats } //dispose (tstResult); {array of record: class x tst Score results} //dispose (TstSetTargets); } //END of MAIN METHOD.