/// <summary> /// Train to a specific error, using the specified training method, send the /// output to the console. /// </summary> /// /// <param name="train">The training method.</param> /// <param name="error">The desired error level.</param> public static void TrainToError(IMLTrain train, double error) { int epoch = 1; Console.Out.WriteLine(@"Beginning training..."); do { train.Iteration(); Console.Out.WriteLine(@"Iteration #" + Format.FormatInteger(epoch) + @" Error:" + Format.FormatPercent(train.Error) + @" Target Error: " + Format.FormatPercent(error)); epoch++; } while ((train.Error > error) && !train.TrainingDone); train.FinishTraining(); }
/// <summary> /// Perform the training. /// </summary> /// /// <param name="train">The training method.</param> /// <param name="method">The ML method.</param> /// <param name="trainingSet">The training set.</param> private void PerformTraining(IMLTrain train, IMLMethod method, IMLDataSet trainingSet) { ValidateNetwork.ValidateMethodToData(method, trainingSet); double targetError = Prop.GetPropertyDouble( ScriptProperties.MlTrainTargetError); Analyst.ReportTrainingBegin(); int maxIteration = Analyst.MaxIteration; do { train.Iteration(); Analyst.ReportTraining(train); } while ((train.Error > targetError) && !Analyst.ShouldStopCommand() && !train.TrainingDone && ((maxIteration == -1) || (train.IterationNumber < maxIteration))); train.FinishTraining(); Analyst.ReportTrainingEnd(); }
/// <summary> /// Entraine le réseau. /// </summary> public void EntrainementReseau() { // Entrainement du réseau. double erreurEntrainement = 0; double erreurValidation = 0; int epoch = 1; do { train.Iteration(); // Entrainement du réseau. erreurEntrainement = Reseau.CalculateError(TrainingSet); ListeErreurEntrainement.Add(erreurEntrainement); if (erreurEntrainement < ErreurOptimaleEntrainement) { ErreurOptimaleEntrainement = erreurEntrainement; ReseauOptimalEntrainement = (BasicNetwork)Reseau.Clone(); } // Validation du réseau. erreurValidation = Reseau.CalculateError(ValidationSet); ListeErreurValidation.Add(erreurValidation); if (erreurValidation < ErreurOptimaleValidation) { ErreurOptimaleValidation = erreurValidation; ReseauOptimalValidation = (BasicNetwork)Reseau.Clone(); } epoch++; } while (epoch < NbEpochMax);// && erreurEntrainement != 0 && erreurValidation != 0); train.FinishTraining(); }
/// <summary> /// Train the network, using the specified training algorithm, and send the /// output to the console. /// </summary> /// <param name="train">The training method to use.</param> /// <param name="network">The network to train.</param> /// <param name="trainingSet">The training set.</param> /// <param name="seconds">The second to train for.</param> public static void TrainConsole(IMLTrain train, BasicNetwork network, IMLDataSet trainingSet, double seconds) { int epoch = 1; double remaining; Console.WriteLine(@"Beginning training..."); long start = Environment.TickCount; do { train.Iteration(); double current = Environment.TickCount; double elapsed = (current - start) / 1000; remaining = seconds - elapsed; Console.WriteLine(@"Iteration #" + Format.FormatInteger(epoch) + @" Error:" + Format.FormatPercent(train.Error) + @" elapsed time = " + Format.FormatTimeSpan((int)elapsed) + @" time left = " + Format.FormatTimeSpan((int)remaining)); epoch++; } while (remaining > 0 && !train.TrainingDone); train.FinishTraining(); }
/// <summary> /// Train the network, using the specified training algorithm, and send the /// output to the console. /// </summary> /// <param name="train">The training method to use.</param> /// <param name="network">The network to train.</param> /// <param name="trainingSet">The training set.</param> /// <param name="minutes">The number of minutes to train for.</param> public static void TrainConsole(IMLTrain train, BasicNetwork network, IMLDataSet trainingSet, int minutes) { int epoch = 1; long remaining; Console.WriteLine(@"Beginning training..."); long start = Environment.TickCount; do { train.Iteration(); long current = Environment.TickCount; long elapsed = (current - start)/1000; remaining = minutes - elapsed/60; Console.WriteLine(@"Iteration #" + Format.FormatInteger(epoch) + @" Error:" + Format.FormatPercent(train.Error) + @" elapsed time = " + Format.FormatTimeSpan((int) elapsed) + @" time left = " + Format.FormatTimeSpan((int) remaining*60)); epoch++; } while (remaining > 0 && !train.TrainingDone); train.FinishTraining(); }
/// <summary> /// Perform the training. /// </summary> /// <param name="train">The training method.</param> /// <param name="method">The ML method.</param> /// <param name="trainingSet">The training set.</param> private void PerformTraining(IMLTrain train, IMLMethod method, IMLDataSet trainingSet) { ValidateNetwork.ValidateMethodToData(method, trainingSet); double targetError = Prop.GetPropertyDouble( ScriptProperties.MlTrainTargetError); Analyst.ReportTrainingBegin(); int maxIteration = Analyst.MaxIteration; if (train.ImplementationType == TrainingImplementationType.OnePass) { train.Iteration(); Analyst.ReportTraining(train); } else { do { train.Iteration(); Analyst.ReportTraining(train); } while ((train.Error > targetError) && !Analyst.ShouldStopCommand() && !train.TrainingDone && ((maxIteration == -1) || (train.IterationNumber < maxIteration))); } train.FinishTraining(); Analyst.ReportTrainingEnd(); }
private void x0d87de1eb44df41c(IMLTrain xd87f6a9c53c2ed9f, IMLMethod x1306445c04667cc7, IMLDataSet x1c9e132f434262d8) { int maxIteration; ValidateNetwork.ValidateMethodToData(x1306445c04667cc7, x1c9e132f434262d8); double propertyDouble = base.Prop.GetPropertyDouble("ML:TRAIN_targetError"); base.Analyst.ReportTrainingBegin(); if ((((uint) maxIteration) & 0) == 0) { if (2 == 0) { goto Label_0038; } maxIteration = base.Analyst.MaxIteration; if (0xff != 0) { goto Label_0038; } } Label_001B: if (!xd87f6a9c53c2ed9f.TrainingDone && ((maxIteration == -1) || (xd87f6a9c53c2ed9f.IterationNumber < maxIteration))) { goto Label_0038; } Label_0023: xd87f6a9c53c2ed9f.FinishTraining(); base.Analyst.ReportTrainingEnd(); return; Label_0038: xd87f6a9c53c2ed9f.Iteration(); base.Analyst.ReportTraining(xd87f6a9c53c2ed9f); if ((xd87f6a9c53c2ed9f.Error <= propertyDouble) || base.Analyst.ShouldStopCommand()) { goto Label_0023; } goto Label_001B; }
public static void TrainToError(IMLTrain train, IMLDataSet trainingSet, double error) { string[] strArray; int i = 1; if ((((uint) i) - ((uint) error)) <= uint.MaxValue) { goto Label_00AF; } goto Label_0050; Label_0037: if ((train.Error > error) && !train.TrainingDone) { goto Label_00B9; } train.FinishTraining(); if ((((uint) i) | 3) != 0) { return; } goto Label_00AF; Label_0050: strArray[1] = Format.FormatInteger(i); do { if (0 != 0) { goto Label_0037; } strArray[2] = " Error:"; } while ((((uint) error) + ((uint) i)) > uint.MaxValue); strArray[3] = Format.FormatPercent(train.Error); strArray[4] = " Target Error: "; strArray[5] = Format.FormatPercent(error); Console.WriteLine(string.Concat(strArray)); i++; goto Label_0037; Label_00AF: Console.WriteLine("Beginning training..."); Label_00B9: train.Iteration(); strArray = new string[6]; strArray[0] = "Iteration #"; goto Label_0050; }
public static void TrainToError(IMLTrain train, double error) { int i = 1; if ((((uint) i) | 8) != 0) { goto Label_0048; } Label_001A: if (0 == 0) { return; } Label_0048: Console.Out.WriteLine("Beginning training..."); Label_0057: train.Iteration(); Console.Out.WriteLine("Iteration #" + Format.FormatInteger(i) + " Error:" + Format.FormatPercent(train.Error) + " Target Error: " + Format.FormatPercent(error)); i++; while (train.Error > error) { if (!train.TrainingDone) { goto Label_0057; } break; } train.FinishTraining(); if (1 != 0) { goto Label_001A; } goto Label_0048; }
public static void TrainConsole(IMLTrain train, BasicNetwork network, IMLDataSet trainingSet, int minutes) { long num2; long num4; long num5; int i = 1; Console.WriteLine("Beginning training..."); long tickCount = Environment.TickCount; goto Label_018E; Label_0025: train.FinishTraining(); if ((((uint) num5) & 0) != 0) { goto Label_018E; } return; Label_003A: if (((((uint) minutes) - ((uint) tickCount)) >= 0) && (0 == 0)) { goto Label_0025; } Label_0052: if (num2 > 0L) { if (!train.TrainingDone) { goto Label_018E; } goto Label_003A; } goto Label_0025; Label_018E: train.Iteration(); Label_0194: num4 = Environment.TickCount; num5 = (num4 - tickCount) / 0x3e8L; num2 = minutes - (num5 / 60L); while (true) { string[] strArray = new string[8]; if ((((uint) num5) | 4) == 0) { goto Label_0194; } strArray[0] = "Iteration #"; strArray[1] = Format.FormatInteger(i); strArray[2] = " Error:"; strArray[3] = Format.FormatPercent(train.Error); strArray[4] = " elapsed time = "; if ((((uint) i) + ((uint) i)) >= 0) { if ((((uint) num4) & 0) == 0) { if ((((uint) minutes) + ((uint) minutes)) > uint.MaxValue) { goto Label_0025; } if (((uint) num5) > uint.MaxValue) { goto Label_003A; } strArray[5] = Format.FormatTimeSpan((int) num5); strArray[6] = " time left = "; } strArray[7] = Format.FormatTimeSpan(((int) num2) * 60); Console.WriteLine(string.Concat(strArray)); i++; goto Label_0052; } } }