public TrainingParameters() { InitializeComponent(); Data = new TrainingRate(); DataContext = Data; }
public void PrepareTrainingData(TrainingRate learningParameters, int epoch, ref int index, ref bool stop) { if (learningParameters.Distorted) { if (((epoch-1) % learningParameters.SameDistortionsForNEpochs) == 0) { bool parameterChanged = false; if (SeverityFactor != learningParameters.SeverityFactor) { SeverityFactor = learningParameters.SeverityFactor; parameterChanged = true; } if (MaxScaling != learningParameters.MaxScaling) { MaxScaling = learningParameters.MaxScaling; parameterChanged = true; } if (MaxRotation != learningParameters.MaxRotation) { MaxRotation = learningParameters.MaxRotation; parameterChanged = true; } if (ElasticSigma != learningParameters.ElasticSigma) { ElasticSigma = learningParameters.ElasticSigma; parameterChanged = true; } if (ElasticScaling != learningParameters.ElasticScaling) { ElasticScaling = learningParameters.ElasticScaling; parameterChanged = true; } if (parameterChanged) CalculateGaussianKernel(); PreparedTrainingPatterns = new DoubleImageData[TrainingPatternsCount]; for (index = 0; index < TrainingPatternsCount; index++) { if (stop) break; PreparedTrainingPatterns[index] = new DoubleImageData(TrainingPatterns[index].Label, GetDistortedPattern(index, true)); } } } else { PreparedTrainingPatterns = TrainingPatterns; } }
public void AddGlobalTrainingRate(TrainingRate rate, Boolean clear = true) { if (TrainingRates == null) TrainingRates = new List<TrainingRate>(); if ((TrainingRates != null) && (clear)) TrainingRates.Clear(); if (rate.DecayFactor == 1D) { TrainingRates.Add(rate); int numEpochs = 0; foreach (TrainingRate aRate in TrainingRates) { numEpochs += aRate.Epochs; } } else { // Decaying Training Rate if (rate.Epochs < rate.DecayAfterEpochs) rate.DecayAfterEpochs = rate.Epochs; int totIteration = rate.Epochs / rate.DecayAfterEpochs; double newRating = rate.Rate; for (int i = 0; i < totIteration; i++) { TrainingRates.Add(new TrainingRate(newRating, rate.DecayAfterEpochs, rate.MinimumRate, rate.DecayFactor, rate.DecayAfterEpochs, rate.WeightSaveTreshold, rate.Distorted, rate.SameDistortionsForNEpochs, rate.SeverityFactor, rate.MaxScaling, rate.MaxRotation, rate.ElasticSigma, rate.ElasticScaling)); if (newRating * rate.DecayFactor > rate.MinimumRate) newRating *= rate.DecayFactor; else newRating = rate.MinimumRate; } if ((totIteration * rate.DecayAfterEpochs) < rate.Epochs) { TrainingRates.Add(new TrainingRate(newRating, rate.Epochs - (totIteration * rate.DecayAfterEpochs), rate.MinimumRate, rate.DecayFactor, rate.DecayAfterEpochs, rate.WeightSaveTreshold, rate.Distorted, rate.SameDistortionsForNEpochs, rate.SeverityFactor, rate.MaxScaling, rate.MaxRotation, rate.ElasticSigma, rate.ElasticScaling)); } } }
public TrainingParametersEditor() { Data = new TrainingRate(true); InitializeComponent(); }
private void TestingTask() { avgMSE = 0; misrecognitions = 0; curIndex = 0; testingPageViewModel.CurrentState = TestingStates.PreparingData; TrainingRate rate = new TrainingRate(testingPageViewModel.UseDistortions); if (testingPageViewModel.UseDistortions) { rate.SeverityFactor = testingPageViewModel.SeverityFactor; rate.MaxScaling = testingPageViewModel.MaxScaling; rate.MaxRotation = testingPageViewModel.MaxRotation; rate.ElasticScaling = testingPageViewModel.ElasticScaling; rate.ElasticSigma = testingPageViewModel.ElasticSigma; } pageViewModel.DataProvider.PrepareTrainingData(rate, 1, ref curIndex, ref testingStopped); testingPageViewModel.CurrentState = TestingStates.Testing; TestPattern(ref curIndex, ref testingStopped); testingPageViewModel.CurrentState = TestingStates.Idle; while (testingPageViewModel.CurrentState == TestingStates.Idle) { Thread.SpinWait(1); if (testingStopped) break; } testingStopped = true; }