public void TestLMA() { IMLDataSet trainingData = new BasicMLDataSet(XOR.XORInput, XOR.XORIdeal); BasicNetwork network = NetworkUtil.CreateXORNetworkUntrained(); IMLTrain rprop = new LevenbergMarquardtTraining(network, trainingData); NetworkUtil.TestTraining(rprop, 0.03); }
public void Execute(IExampleInterface app) { IMLDataSet trainingData = GenerateTraining(InputOutputCount, Compl); IMLMethod method = EncogUtility.SimpleFeedForward(InputOutputCount, HiddenCount, 0, InputOutputCount, false); var train = new LevenbergMarquardtTraining((BasicNetwork) method, trainingData); EncogUtility.TrainToError(train, 0.01); EncogFramework.Instance.Shutdown(); }
/// <summary> /// Create a LMA trainer. /// </summary> /// /// <param name="method">The method to use.</param> /// <param name="training">The training data to use.</param> /// <param name="argsStr">The arguments to use.</param> /// <returns>The newly created trainer.</returns> public IMLTrain Create(IMLMethod method, IMLDataSet training, String argsStr) { if (!(method is BasicNetwork)) { throw new EncogError( "LMA training cannot be used on a method of type: " + method.GetType().FullName); } IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr); var holder = new ParamsHolder(args); var result = new LevenbergMarquardtTraining( (BasicNetwork) method, training); return result; }
/// <summary> /// Create a LMA trainer. /// </summary> /// /// <param name="method">The method to use.</param> /// <param name="training">The training data to use.</param> /// <param name="argsStr">The arguments to use.</param> /// <returns>The newly created trainer.</returns> public IMLTrain Create(IMLMethod method, IMLDataSet training, String argsStr) { if (!(method is BasicNetwork)) { throw new EncogError( "LMA training cannot be used on a method of type: " + method.GetType().FullName); } IDictionary<String, String> args = ArchitectureParse.ParseParams(argsStr); var holder = new ParamsHolder(args); bool useReg = holder.GetBoolean( MLTrainFactory.PropertyBayesianRegularization, false, false); var result = new LevenbergMarquardtTraining( (BasicNetwork) method, training) {UseBayesianRegularization = useReg}; return result; }
public IMLTrain Create(IMLMethod method, IMLDataSet training, string argsStr) { bool flag; LevenbergMarquardtTraining training3; if (method is BasicNetwork) { flag = new ParamsHolder(ArchitectureParse.ParseParams(argsStr)).GetBoolean("BAYES_REG", false, false); training3 = new LevenbergMarquardtTraining((BasicNetwork) method, training); if (3 == 0) { LevenbergMarquardtTraining training2; return training2; } } else if (0 == 0) { throw new EncogError("LMA training cannot be used on a method of type: " + method.GetType().FullName); } training3.UseBayesianRegularization = flag; if (0 == 0) { } return training3; }
public void Train(BasicNetwork network, IMLDataSet training) { IMLTrain trainMain = new LevenbergMarquardtTraining(network, training); // train the neural network var stop = new StopTrainingStrategy(); ICalculateScore score = new TrainingSetScore(trainMain.Training); IMLTrain trainAlt = new NeuralSimulatedAnnealing(network, score, 10, 2, 100); trainMain.AddStrategy(new HybridStrategy(trainAlt)); trainMain.AddStrategy(stop); int epoch = 0; while (!stop.ShouldStop() && trainMain.IterationNumber < 1500) { trainMain.Iteration(); Console.WriteLine("Training " + ", Epoch #" + epoch + " Error:" + trainMain.Error); epoch++; } }
private double TrainNetwork(String what, BasicNetwork network, IMLDataSet trainingSet, string Method) { // train the neural network ICalculateScore score = new TrainingSetScore(trainingSet); IMLTrain trainAlt = new NeuralSimulatedAnnealing(network, score, 10, 2, 100); IMLTrain trainMain; if (Method.Equals("Leven")) { Console.WriteLine("Using LevenbergMarquardtTraining"); trainMain = new LevenbergMarquardtTraining(network, trainingSet); } else trainMain = new Backpropagation(network, trainingSet); var stop = new StopTrainingStrategy(); trainMain.AddStrategy(new Greedy()); trainMain.AddStrategy(new HybridStrategy(trainAlt)); trainMain.AddStrategy(stop); int epoch = 0; while (!stop.ShouldStop()) { trainMain.Iteration(); app.WriteLine("Training " + what + ", Epoch #" + epoch + " Error:" + trainMain.Error); epoch++; } return trainMain.Error; }