/// <summary> /// Called on each testing iteration of the sequence model. /// </summary> /// <param name="sender">Specifies the event sender.</param> /// <param name="e">Specifies the event args.</param> private void m_mycaffe_OnTestingIteration(object sender, TestingIterationArgs <float> e) { float fAccuracy = m_rgAccuracyTraining.Average(); m_plotsSequenceAccuracyTrain.Add(m_nTotalSequences, fAccuracy * 100); if (m_plotsSequenceAccuracyTrain.Count > 100) { m_plotsSequenceAccuracyTrain.RemoveAt(0); } m_rgAccuracyTesting.Add((float)e.Accuracy); m_rgAccuracyTesting.RemoveAt(0); fAccuracy = m_rgAccuracyTesting.Average(); m_plotsSequenceAccuracyTest.Add(m_nTotalSequences, fAccuracy * 100); if (m_plotsSequenceAccuracyTest.Count > 100) { m_plotsSequenceAccuracyTest.RemoveAt(0); } PlotCollectionSet set = new PlotCollectionSet(); set.Add(m_plotsSequenceAccuracyTrain); set.Add(m_plotsSequenceAccuracyTest); Image img = SimpleGraphingControl.QuickRender(set, pbImageAccuracy.Width, pbImageAccuracy.Height, false, null, null, false, m_rgZeroLine); m_bw.ReportProgress(1, new Tuple <Image, int>(img, 1)); }
public PlotCollectionSet GetLastData(int nLookahead = 0, bool bRemove = false) { if (m_data.Count == 0) { return(null); } if (nLookahead > 0 && bRemove) { throw new Exception("Removing data is not supported when retrieving data with a lookahead."); } PlotCollectionSet lastData = new PlotCollectionSet(); List <PlotCollection> rgPlots = new List <PlotCollection>(); for (int i = 0; i < m_data.Count; i++) { PlotCollectionSet dataFrame = m_data[i]; if (dataFrame.Count == 0) { return(null); } PlotCollection plots = new PlotCollection("Frame " + i.ToString()); for (int j = 0; j < dataFrame.Count; j++) { PlotCollection framePlots = dataFrame[j]; if (framePlots.Count == 0) { return(null); } Plot last = framePlots[framePlots.Count - (1 + nLookahead)]; if (last.Name == null) { last.Name = framePlots.Name; } plots.Add(last); if (bRemove) { framePlots.RemoveAt(framePlots.Count - 1); } } lastData.Add(plots); } if (bRemove) { m_output = m_surface.BuildGraph(m_config, m_data); SimpleGraphingControl_Resize(this, EventArgs.Empty); ScrollToEnd(false); } return(lastData); }
public void AddData(PlotCollectionSet data, bool bMaintainCount, bool bRender = false) { if (data.Count != m_data.Count) { throw new Exception("The number of plot collections must match the number of plot sets used by the graph."); } List <string> rgUpdated = new List <string>(); for (int i = 0; i < data.Count; i++) { PlotCollectionSet dataFrame = m_data[i]; if (rgUpdated.Contains(dataFrame[0].Name)) { continue; } PlotCollection dataToAdd = data[i]; if (dataFrame.Count != dataToAdd.Count) { throw new Exception("The number of data items to add must match the number of plot collections in the frame!"); } for (int j = 0; j < dataFrame.Count; j++) { PlotCollection dataFrameItems = dataFrame[j]; Plot plot = dataToAdd[j]; dataFrameItems.Add(plot); if (bMaintainCount) { dataFrameItems.RemoveAt(0); } } rgUpdated.Add(dataFrame[0].Name); } m_output = m_surface.BuildGraph(m_config, m_data); SimpleGraphingControl_Resize(this, EventArgs.Empty); ScrollToEnd(bRender); }
/// <summary> /// Called on each training iteration of the sequence model used to encode each detected hand written character /// and then decode the encoding into the proper section of the Sin curve. /// </summary> /// <param name="sender">Specifies the event sender.</param> /// <param name="e">Specifies the event args.</param> private void m_mycaffe_OnTrainingIteration(object sender, TrainingIterationArgs <float> e) { if (m_sw.Elapsed.TotalMilliseconds > 1000) { m_log.Progress = e.Iteration / (double)m_model.Iterations; m_log.WriteLine("Seq2Seq Epoch " + m_nTotalEpochs.ToString() + " Sequence " + m_nTotalSequences.ToString() + " Iteration " + e.Iteration.ToString() + " of " + m_model.Iterations.ToString() + ", loss = " + e.SmoothedLoss.ToString(), true); m_sw.Restart(); m_fTotalCost += (float)e.SmoothedLoss; m_nTotalIter1++; float fLoss = m_fTotalCost / m_nTotalIter1; m_plotsSequenceLoss.Add(m_nTotalSequences, fLoss); if (m_plotsSequenceLoss.Count > 2000) { m_plotsSequenceLoss.RemoveAt(0); } Image img = SimpleGraphingControl.QuickRender(m_plotsSequenceLoss, pbImageLoss.Width, pbImageLoss.Height, false, null, null, true, m_rgZeroLine); m_bw.ReportProgress(1, new Tuple <Image, int>(img, 0)); } }