3using System.Collections.Generic;
6using System.Threading.Tasks;
10#pragma warning disable 1591
12 public class LabelStats
14 List<LabelDescriptor> m_rgLabels;
15 List<ulong> m_rgCounts;
16 List<ulong> m_rgBoosts;
17 object m_objSync =
new object();
18 object m_objSyncBoost =
new object();
20 public LabelStats(
int nCount)
22 m_rgLabels =
new List<LabelDescriptor>(nCount);
23 m_rgCounts =
new List<ulong>(nCount);
24 m_rgBoosts =
new List<ulong>();
31 m_rgBoosts =
new List<ulong>();
35 private int find(
int nLabel)
37 for (
int i = 0; i < m_rgLabels.Count; i++)
39 if (m_rgLabels[i].Label == nLabel)
50 m_rgLabels.Add(label);
52 m_rgLabels = m_rgLabels.OrderBy(p => p.Label).ToList();
56 public void UpdateLabel(
int nLabel)
58 int nIdx = find(nLabel);
63 public void UpdateBoost(
int nBoost)
67 while (m_rgBoosts.Count <= nBoost)
76 public Dictionary<int, ulong> GetCounts()
80 Dictionary<int, ulong> rg =
new Dictionary<int, ulong>();
82 for (
int i = 0; i < m_rgLabels.Count; i++)
84 rg.Add(m_rgLabels[i].Label, m_rgCounts[i]);
91 public string GetQueryBoostHitPercentsAsText(
int nMax = 10)
98 for (
int i = 0; i < m_rgBoosts.Count; i++)
100 dfTotal += m_rgBoosts[i];
103 for (
int i = 0; i < m_rgBoosts.Count && i < nMax; i++)
105 double dfPct = m_rgBoosts[i] / dfTotal;
106 strOut += dfPct.ToString(
"P");
111 if (m_rgBoosts.Count > nMax)
114 strOut = strOut.TrimEnd(
',');
121 public string GetQueryLabelHitPercentsAsText(
int nMax = 10)
128 for (
int i = 0; i < m_rgCounts.Count; i++)
130 dfTotal += m_rgCounts[i];
133 for (
int i = 0; i < m_rgCounts.Count && i < nMax; i++)
135 double dfPct = m_rgCounts[i] / dfTotal;
136 strOut += dfPct.ToString(
"P");
141 if (m_rgCounts.Count > nMax)
144 strOut = strOut.TrimEnd(
',');
151 public string GetQueryLabelEpochAsText(
int nMax = 10)
157 for (
int i = 0; i < m_rgLabels.Count && i < nMax; i++)
159 int nImageCount = m_rgLabels[i].ImageCount;
160 double dfPct = (nImageCount == 0) ? 0 : (
double)m_rgCounts[i] / nImageCount;
161 strOut += dfPct.ToString(
"N2");
166 if (m_rgCounts.Count > nMax)
169 strOut = strOut.TrimEnd(
',');
177#pragma warning restore 1591
The LabelDescriptor class describes a single label.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.db.image namespace contains all image database related classes.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...