/// <summary> /// Run this instance. /// </summary> public static void Run() { //Build Network _TestNetworkStructure = new Network(); BuildStructure(); _TestNetworkStructure.RandomiseWeights(0.01d); //PrepData Double[][] dataSet = StandardDeviationVariance.ProduceDataset("TestData/Mackey-Glass-Pure.csv").DataSet; //Prepare training activity _SlidingWindowTraining = new SlidingWindow(); _SlidingWindowTraining.SetTargetNetwork(_TestNetworkStructure); // the target network for the training to take place on _SlidingWindowTraining.SetMomentum(0.7f); // The ammount of the previous weight change applied to current weight change - google if u need to know more _SlidingWindowTraining.SetLearningRate(0.004f); // The rate at which the neural entwork learns (the more agressive this is the harded itll be for the network) _SlidingWindowTraining.SetDatasetReservedLength(0); // How many elements off the end of the dataset should not be used for training _SlidingWindowTraining.SetDistanceToForcastHorrison(3); // How far beyond the window should be be trying to predict _SlidingWindowTraining.SetWindowWidth(12); // The window of elements that should be presented before the backward pass is performed _SlidingWindowTraining.SetMaximumEpochs(300); // The maximum number of epochs the network can train for _SlidingWindowTraining.SetInputNodes(_InputLayerNodes); // Setting the nodes that are used for input _SlidingWindowTraining.SetOutputNodes(_OuputLayerNodes); // Setting the nodes that are generating output _SlidingWindowTraining.SetWorkingDataset(dataSet); // Setting the working dataset for the training phase _SlidingWindowTraining.SetDynamicLearningRateDelegate(DynamicLearningRate); // Sets the contect layers that are used as part of the training (have to updates) List<Base> contextLayers = new List<Base> {_ContextLayer}; _SlidingWindowTraining.SetRecurrentConextLayers(contextLayers); //////////////////////////////////////////////// //////////////////////////////////////////////// Console.WriteLine("Starting Training"); _SlidingWindowTraining.Start(); Thread.Sleep(1000); while (_SlidingWindowTraining.IsRunning()) Thread.Sleep(20); //////////////////////////////////////////////// //////////////////////////////////////////////// Console.WriteLine("Starting Testing"); Lib.Activity.Testing.SlidingWindow slidingWindowTesting = new Lib.Activity.Testing.SlidingWindow(); slidingWindowTesting.SetDatasetReservedLength(0); slidingWindowTesting.SetInputNodes(_InputLayerNodes); slidingWindowTesting.SetOutputNodes(_OuputLayerNodes); slidingWindowTesting.SetRecurrentConextLayers(contextLayers); slidingWindowTesting.SetWorkingDataset(dataSet); slidingWindowTesting.SetWindowWidth(12); slidingWindowTesting.SetDistanceToForcastHorrison(3); slidingWindowTesting.SetTargetNetwork(_TestNetworkStructure); Lib.Activity.Testing.SlidingWindow.SlidingWindowTestResults result = (Lib.Activity.Testing.SlidingWindow.SlidingWindowTestResults) slidingWindowTesting.TestNetwork(); Console.WriteLine(result.Rmse); Functions.PrintArrayToFile(result.ActualOutputs, "ActualOutputs.csv"); Functions.PrintArrayToFile(result.ExpectedOutputs, "ExpectedOutputs.csv"); Console.WriteLine("Comparing Against Random Walk 3 Step"); Console.WriteLine(Math.Round(RandomWalkCompare.CalculateError(result.ExpectedOutputs, result.ActualOutputs, 3)[0]*100, 3)); Console.WriteLine("Comparing Against Random Walk 2 Step"); Console.WriteLine(Math.Round(RandomWalkCompare.CalculateError(result.ExpectedOutputs, result.ActualOutputs, 2)[0]*100, 3)); Console.WriteLine("Comparing Against Random Walk 1 Step"); Console.WriteLine(Math.Round(RandomWalkCompare.CalculateError(result.ExpectedOutputs, result.ActualOutputs, 1)[0]*100, 3)); Console.ReadKey(); }