public void Learn() { Outputs.Clear(); var error = 0.0; double testError = 0.0; for (var i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); Train(hiddenLayerOutputs[i], SampleRepository.TrainSamples[i].ExpectedValues.First()); Outputs.Add(_neuron.Output); } for (int i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); error += _neuron.CalculateError(SampleRepository.TrainSamples[i].ExpectedValues.First()); } for (int i = 0; i < SampleRepository.TestSamples.Count; i++) { CalculateNetworkOutput(new SamplePoint(SampleRepository.TestSamples[i].Inputs)); testError += _neuron.CalculateError(SampleRepository.TestSamples[i].ExpectedValues.First()); } TotalErrors.Add(error / hiddenLayerOutputs.Count); TotalTestErrors.Add(testError / SampleRepository.TestSamples.Count); }
public void SetUpClassificationAlgorithm() { _prevOutputWeightError = 0; Centroid.ResetNextId(); CalculateHiddenLayerOutputs(); InitOutputLayerWeights(); TotalErrors.Clear(); TotalTestErrors.Clear(); }
public void UpdateRiserPropertyToRemote() { var riserName = string.Format("{0}_{1}_{2}_{3}_{4}", Channel, Overpass, Way, Product, Riser); Data.UpdateRiserProperty(riserName, "TotalRequests", TotalRequests.ToString("0")); Data.UpdateRiserProperty(riserName, "TotalErrors", TotalErrors.ToString("0")); Data.UpdateRiserProperty(riserName, "BarometerValue", BarometerValue.ToString("0")); Data.UpdateRiserProperty(riserName, "Channel", Channel.ToString("0")); }
public void StuffDooer() { CalculateHiddenLayerOutputs(); InitOutputLayerWeights(); TotalErrors.Clear(); var error = 0.0; for (var i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); Train(hiddenLayerOutputs[i], SampleRepository.TrainSamples[i].ExpectedValues.First()); error += _neuron.CalculateError(SampleRepository.TrainSamples[i].ExpectedValues.First()); } TotalErrors.Add(error); }
public void Create() { InitializePerformanceCounters(); if (ramCounter.NextValue() < (ramTotal * MemorySafe)) { WriteInfo(string.Format("Safe Memory Limit"), string.Format("Available = {0} < Safe Limit = {1}MB", getAvailableRAM(), ramTotal * MemorySafe)); return; } DateTime startTime = DateTime.Now; int totalRecords = 0; lines = new List <OUImportationLine>(); // TODO: Fetch keywords to make it faster on the loops. trends = new List <Trend>(trendRepository.GetAll()); silouhettes = new List <Silouhette>(silouhetteRepository.GetAll()); patterns = new List <Pattern>(patternRepository.GetAll()); colorFamilies = new List <ColorFamily>(colorFamilyRepository.GetAll()); outfitUpdaters = new List <OutfitUpdater>(outfitUpdaterRepository.GetFor(Partner)); wordsForDiscard.Add(" men"); wordsForDiscard.Add(" mens"); wordsForDiscard.Add(" men's"); wordsForDiscard.Add(" men´s"); wordsForDiscard.Add("kid"); wordsForDiscard.Add("kids"); wordsForDiscard.Add("kid's"); wordsForDiscard.Add("kid´s"); // Retrieve Keywords // TODO: Limit by partner colorFamilyKeywords = new Repository <ColorFamilyKeywordsByPartner>().GetAll(); patternKeywords = new Repository <PatternKeywordsByPartner>().GetAll(); silouhetteKeywords = new Repository <SilouhetteKeywordsByPartner>().GetAll(); Write("--------------------------------------------------------------------------------"); Write(string.Format("{0} - {1}\t\t{2}\t\t{3}\t{4}\t{5}", "Time", "Process Type", "Action", "CPU Usage", "RAM Available(MB)", "Records OK")); WriteFullInfo("Start"); //REVIEW: The ZapposClassBuilder should read the file and create an event for the loop, returning an //REVIEW: understandable object that we can interchange when we have another builder. This way we can not //REVIEW: change the builder in a truly manner. Right now, is kind of complex and not clear how to change it. //REVIEW: That way is simple to change from reading from a file or other providers. //REVIEW: This class should worry about checking if the line is valid and import it in our system. DelimitedClassBuilder cb = ouImportationClassBuilder.CreateClassBuilder(Separator, HaveHeader); //REVIEW: Why is these here? We always read line at line. if (Sync) { FileHelperEngine engine = new FileHelperEngine(cb.CreateRecordClass()); object[] items = engine.ReadFile(path + Filename); totalRecords = items.Length; WriteFullInfo("Ready"); for (int i = 0; i < items.Length; i++) { actualLine = i; if (HaveHeader) { actualLine++; } ProcessOUImportationLine(items[i]); CheckLimits(); } } else { FileHelperAsyncEngine engine = new FileHelperAsyncEngine(cb.CreateRecordClass()); engine.BeginReadFile(path + Filename); WriteFullInfo("Ready"); while (engine.ReadNext() != null) { actualLine = totalRecords + 1; if (HaveHeader) { actualLine++; } ProcessOUImportationLine(engine.LastRecord); CheckLimits(); totalRecords++; } ProcessList(); } DateTime endTime = DateTime.Now; TimeSpan span = endTime - startTime; WriteFullInfo("Finish"); Write("--------------------------------------------------------------------------------"); Write(string.Format("{0} - {1} {2} {3} records in {4} seconds", endTime.ToLongTimeString(), Process, "Finish", totalRecords, span.TotalSeconds.ToString("0"))); WriteInfo("Total lines added/modified", linesOk.Count.ToString()); WriteInfo("Total errors", TotalErrors.ToString()); //WriteInfo("Lines with errors", string.Join(",", linesWithErrors.ToArray())); Write("--------------------------------------------------------------------------------"); }