public static double TrainNetwork(String what, FreeformNetwork network, IMLDataSet trainingSet) { ICalculateScore score = new TrainingSetScore(trainingSet); IMLTrain trainAlt = new NeuralSimulatedAnnealing( network, score, 10, 2, 100); IMLTrain trainMain = new FreeformBackPropagation(network, trainingSet,0.00001, 0.0); StopTrainingStrategy stop = new StopTrainingStrategy(); trainMain.AddStrategy(new Greedy()); trainMain.AddStrategy(new HybridStrategy(trainAlt)); trainMain.AddStrategy(stop); EncogUtility.TrainToError(trainMain, 0.01); return trainMain.Error; }
public void Execute(IExampleInterface app) { // create a neural network, without using a factory var network = new FreeformNetwork(); IFreeformLayer inputLayer = network.CreateInputLayer(2); IFreeformLayer hiddenLayer1 = network.CreateLayer(3); IFreeformLayer outputLayer = network.CreateOutputLayer(1); network.ConnectLayers(inputLayer, hiddenLayer1, new ActivationSigmoid(), 1.0, false); network.ConnectLayers(hiddenLayer1, outputLayer, new ActivationSigmoid(), 1.0, false); network.Reset(); // create training data var trainingSet = new BasicMLDataSet(XORInput, XORIdeal); var train = new FreeformBackPropagation(network, trainingSet, 0.7, 0.2); train.BatchSize = 1; EncogUtility.TrainToError(train, 0.01); EncogUtility.Evaluate(network, trainingSet); EncogFramework.Instance.Shutdown(); }