public void Train() { var network = createNetwork(); IMLDataSet trainingSet = EncogUtility.LoadCSV2Memory(normFile, network.InputCount, 1, false, CSVFormat.English, false); IMLTrain train = new Backpropagation(network, trainingSet); int epoch = 1; int truecases = 0; do { train.Iteration(); Console.WriteLine(@"Epoch #" + epoch + @" Error:" + train.Error); epoch++; } while (train.Error > 0.05); train.FinishTraining(); Console.WriteLine(@"Neural Network Results:"); foreach (IMLDataPair pair in trainingSet) { IMLData output = network.Compute(pair.Input); Console.WriteLine(@" actual=" + output[0] + @",ideal=" + pair.Ideal[0]); if (pair.Ideal[0] == 1 && output[0] > 0.5) { truecases++; } else if (pair.Ideal[0] == 0 && output[0] < 0.5) { truecases++; } } Console.WriteLine(truecases); SerializeObject.Save(networkFile, network); }
public void geneticNeural() { FeedforwardNetwork network = createNetwork(); // train the neural network Console.WriteLine("Determining initial scores"); TicTacToeGenetic train = new TicTacToeGenetic(network, true, NeuralTicTacToe.POPULATION_SIZE, NeuralTicTacToe.MUTATION_PERCENT, NeuralTicTacToe.MATE_PERCENT, this.player2.GetType()); train.UseThreadPool = true; ThreadPool.SetMaxThreads(NeuralTicTacToe.THREAD_POOL_SIZE, NeuralTicTacToe.THREAD_POOL_SIZE); int epoch = 1; DateTime started = DateTime.Now; int minutes = 0; do { train.Iteration(); TimeSpan span = (DateTime.Now - started); minutes = span.Minutes; Console.WriteLine("Epoch #" + epoch + " Error:" + train.getScore() + ",minutes left=" + (NeuralTicTacToe.TRAIN_MINUTES - minutes)); epoch++; } while (minutes < NeuralTicTacToe.TRAIN_MINUTES); SerializeObject.Save("tictactoe.net", train.Network); }
public void TestPersistSerial() { BAMNetwork network = Create(); SerializeObject.Save(SERIAL_FILENAME.ToString(), network); var network2 = (BAMNetwork)SerializeObject.Load(SERIAL_FILENAME.ToString()); ValidateBAM(network2); }
public void TestPersistSerial() { SupportVectorMachine network = Create(); SerializeObject.Save(SERIAL_FILENAME.ToString(), network); SupportVectorMachine network2 = (SupportVectorMachine)SerializeObject.Load(SERIAL_FILENAME.ToString()); Validate(network2); }
public void TestContPersistSerial() { HiddenMarkovModel sourceHMM = BuildContHMM(); SerializeObject.Save(SERIAL_FILENAME.ToString(), sourceHMM); HiddenMarkovModel resultHMM = (HiddenMarkovModel)SerializeObject.Load(SERIAL_FILENAME.ToString()); Validate(resultHMM, sourceHMM); }
public void TestPersistSerial() { NEATPopulation pop = Generate(); SerializeObject.Save(SERIAL_FILENAME.ToString(), pop); NEATPopulation pop2 = (NEATPopulation)SerializeObject.Load(SERIAL_FILENAME.ToString()); Validate(pop2); }
public void TestPersistSerial() { BasicPNN network = create(); SerializeObject.Save(SERIAL_FILENAME.ToString(), network); BasicPNN network2 = (BasicPNN)SerializeObject.Load(SERIAL_FILENAME.ToString()); XOR.VerifyXOR(network2, 0.001); }
public void testPersistSerial() { PrgPopulation pop = Create(); Validate(pop); SerializeObject.Save(SERIAL_FILENAME.ToString(), pop); PrgPopulation pop2 = (PrgPopulation)SerializeObject.Load(SERIAL_FILENAME.ToString()); Validate(pop2); }
public void TestPersistSerial() { HopfieldNetwork network = new HopfieldNetwork(4); network.SetWeight(1, 1, 1); SerializeObject.Save(SERIAL_FILENAME.ToString(), network); HopfieldNetwork network2 = (HopfieldNetwork)SerializeObject.Load(SERIAL_FILENAME.ToString()); ValidateHopfield(network2); }
public void TestPersistSerial() { BoltzmannMachine network = new BoltzmannMachine(4); network.SetWeight(1, 1, 1); network.Threshold[2] = 2; SerializeObject.Save(SERIAL_FILENAME.ToString(), network); BoltzmannMachine network2 = (BoltzmannMachine)SerializeObject.Load(SERIAL_FILENAME.ToString()); ValidateHopfield(network2); }
public void SavePAPContainer(string pathName, string fileName) { if (playerNetworkPool == null) { throw new Exception("Network must be set before the PAP container can be saved out."); } //Save out the PAPContainer (without the network) SerializeObject.Save(pathName + fileName + ".PAPc", this); //Save out the network NNLoadSave.saveNetwork(playerNetworkPool.BaseNetwork, fileName + ".eNN", pathName); }
public void Serialize() { using (SaveFileDialog dialog = new SaveFileDialog()) { dialog.Filter = "ennq files (*.ennq)|*.ennq"; dialog.FilterIndex = 2; dialog.RestoreDirectory = true; if (dialog.ShowDialog() == DialogResult.OK) { SerializeObject.Save(dialog.FileName, Network); } } }
public void Process() { this.network = NetworkUtil.CreateNetwork(); Console.WriteLine("Preparing training sets..."); this.common = new CommonWords(Config.FILENAME_COMMON_WORDS); this.histogramGood = new WordHistogram(this.common); this.histogramBad = new WordHistogram(this.common); // load the good words this.histogramGood.BuildFromFile(Config.FILENAME_GOOD_TRAINING_TEXT); this.histogramGood.BuildComplete(); // load the bad words this.histogramBad.BuildFromFile(Config.FILENAME_BAD_TRAINING_TEXT); this.histogramBad.BuildComplete(); // remove low scoring words this.histogramGood .RemoveBelow((int)this.histogramGood.CalculateMean()); this.histogramBad.RemovePercent(0.99); // remove common words this.histogramGood.RemoveCommon(this.histogramBad); this.histogramGood.Trim(Config.INPUT_SIZE); this.goodAnalysis = new AnalyzeSentences(this.histogramGood, Config.INPUT_SIZE); this.badAnalysis = new AnalyzeSentences(this.histogramGood, Config.INPUT_SIZE); this.goodAnalysis.Process(this.trainingSet, 0.9, Config.FILENAME_GOOD_TRAINING_TEXT); this.badAnalysis.Process(this.trainingSet, 0.1, Config.FILENAME_BAD_TRAINING_TEXT); this.sampleCount = this.trainingSet.Ideal.Count; Console.WriteLine("Processing " + this.sampleCount + " training sets."); AllocateTrainingSets(); CopyTrainingSets(); TrainNetworkBackpropBackprop(); SerializeObject.Save(Config.FILENAME_WHENBORN_NET, this.network); SerializeObject.Save(Config.FILENAME_HISTOGRAM, this.histogramGood); Console.WriteLine("Training complete."); }
public void geneticNeural() { Stopwatch sw = new Stopwatch(); FeedforwardNetwork network = createNetwork(); // train the neural network Console.WriteLine("Determining initial scores"); TicTacToeGenetic train = new TicTacToeGenetic(network, true, NeuralTicTacToe.POPULATION_SIZE, NeuralTicTacToe.MUTATION_PERCENT, NeuralTicTacToe.MATE_PERCENT, this.player2.GetType()); train.UseThreadPool = true; sw.Stop(); string duration = String.Format("Training_time: {0}", sw.Elapsed.Minutes); Console.WriteLine(duration); ThreadPool.SetMaxThreads(NeuralTicTacToe.THREAD_POOL_SIZE, NeuralTicTacToe.THREAD_POOL_SIZE); int epoch = 1; DateTime started = DateTime.Now; int minutes = 0; double error = train.getScore(); do { sw.Start(); error = train.getScore(); if (error > 0) { train.Iteration(); } sw.Stop(); minutes = sw.Elapsed.Minutes; string observation = String.Format("Epoch: {0}, Error:{1}, minutes_left : {2}", epoch, error, (NeuralTicTacToe.TRAIN_MINUTES - minutes)); Console.WriteLine(observation); epoch++; } while (minutes < NeuralTicTacToe.TRAIN_MINUTES && error > 0.00001d); SerializeObject.Save("tictactoe.net", train.Network); }
public void Execute(IExampleInterface app) { this.app = app; this.app = app; IMLDataSet trainingSet = new BasicMLDataSet(XOR_INPUT, XOR_IDEAL); BasicNetwork network = EncogUtility.SimpleFeedForward(2, 6, 0, 1, false); EncogUtility.TrainToError(network, trainingSet, 0.01); double error = network.CalculateError(trainingSet); SerializeObject.Save("encog.ser", network); network = (BasicNetwork)SerializeObject.Load("encog.ser"); double error2 = network.CalculateError(trainingSet); app.WriteLine("Error before save to ser: " + Format.FormatPercent(error)); app.WriteLine("Error before after to ser: " + Format.FormatPercent(error2)); }
public static void Generate(ForestConfig config, bool useOneOf) { var generate = new GenerateData(config); generate.Step1(); generate.Step2(); DataNormalization norm = generate.Step3(useOneOf); // save the normalize object SerializeObject.Save(config.NormalizeFile.ToString(), norm); // create and save the neural network BasicNetwork network = EncogUtility.SimpleFeedForward(norm.GetNetworkInputLayerSize(), config.HiddenCount, 0, norm.GetNetworkOutputLayerSize(), true); EncogDirectoryPersistence.SaveObject(config.TrainedNetworkFile, network); }
/// <summary> /// Saves a normalization to the specified folder with the specified name. /// </summary> /// <param name="directory">The directory.</param> /// <param name="file">The file.</param> /// <param name="normTosave">The norm tosave.</param> public static void SaveNormalization(string directory, string file, DataNormalization normTosave) { SerializeObject.Save(directory + file, normTosave); }
public void saveNeuralNetwork() { SerializeObject.Save("sp500.net", network); }