/// <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(ITrain train, BasicNetwork network, INeuralDataSet 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> /// 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="trainingSet">The training set to use.</param> /// <param name="error">The desired error level.</param> public static void TrainToError(ITrain train, INeuralDataSet trainingSet, double error) { int epoch = 1; Console.WriteLine("Beginning training..."); do { train.Iteration(); Console.WriteLine("Iteration #" + Format.FormatInteger(epoch) + " Error:" + Format.FormatPercent(train.Error) + " Target Error: " + Format.FormatPercent(error)); epoch++; } while (train.Error > error && !train.TrainingDone); train.FinishTraining(); }