public List <BPResponse> BPWatched(BPWDRequest bpr) { List <BPResponse> toret = new List <BPResponse>(bpr.MaxBPs); bool trace = this.Inspector != null; for (int i = 0; i < bpr.MaxBPs; i++) { if (trace) { Inspector.Trace("BP attempt {0}", i + 1); } BPResponse response = this.BP(bpr); toret.Add(response); if (response.Estimate != BPResponseEstimate.Failure) { if (trace) { Inspector.Trace("BPWatched process end, no failures found"); } break; } if (trace) { Inspector.Trace("BP failed to learn network"); } this.Reset(Lo, Hi); } return(toret); }
//util void StartLearning() { Stopped = false; Thread.CurrentThread.Priority = ThreadPriority.Lowest; Image[] bigimgs = Utility.Generate(i => Image.FromFile(@"mnist_train" + i.ToString() + ".jpg"), 10).ToArray(); int idx = 0, total = 0; List <TrainingData> trainingList = new List <TrainingData>(); foreach (double[] input in GetAllImages(bigimgs)) { if (Stopped) { return; } double[] output = Digitalizer.GetOutput(10, idx).ToArray(); Application.DoEvents(); trainingList.Add(new TrainingData(input, output)); GC.Collect(); GC.WaitForPendingFinalizers(); idx = (idx + 1) % 10; if (idx == 0) { total++; BPRequest request = new BPRequest(trainingList.ToArray(), 1) { ShuffleTrainingSet = true }; BPResponse response = Network.BP(request); double eps = response.Epochs[0].Epsilon; double ms = response.BPTime.TotalMilliseconds; trainingList.Clear(); } } StopLearning(); }