4using System.Collections.Generic;
7using System.Threading.Tasks;
22 bool m_bUseUniqueImageIndexes =
true;
23 bool m_bUseUniqueLabelIndexes =
true;
36 m_bUseUniqueLabelIndexes = bUseUniqueLabelIndexes;
37 m_bUseUniqueImageIndexes = bUseUniqueImageIndexes;
51 m_stat.UpdateLabel(sd.
Label);
52 m_stat.UpdateBoost(sd.
Boost);
62 Index.SELECTION_TYPE selType = Index.SELECTION_TYPE.RANDOM;
66 selType = Index.SELECTION_TYPE.SEQUENTIAL;
80 public override int?
GetNextLabel(Index.SELECTION_TYPE type,
bool bBoosted =
false)
86 int? nIdx = rgIdx.GetNextLabel(type,
null, m_bUseUniqueLabelIndexes);
103 return GetNextImage(Index.SELECTION_TYPE.DIRECT,
null,
false, nDirectIdx);
105 Index.SELECTION_TYPE selType = Index.SELECTION_TYPE.RANDOM;
106 bool bBoosted =
false;
110 selType = Index.SELECTION_TYPE.SEQUENTIAL;
131 public override int?
GetNextImage(Index.SELECTION_TYPE type,
int? nLabel =
null,
bool bBoosted =
false,
int nDirectIdx = -1)
137 nIdx = base.GetNextImage(type, nLabel, bBoosted, nDirectIdx);
142 if (type == Index.SELECTION_TYPE.DIRECT)
145 throw new Exception(
"Invalid direct index, must be >= 0.");
148 nIdx = idx.GetIndex(nDirectIdx);
157 nIdx = idx.GetNext(type, m_bUseUniqueImageIndexes);
161 nIdx = idx.GetNext(type, m_bUseUniqueImageIndexes);
177 return m_stat.GetCounts();
186 return m_stat.GetQueryBoostHitPercentsAsText();
195 return m_stat.GetQueryLabelHitPercentsAsText();
204 return m_stat.GetQueryLabelEpochAsText();
213 Dictionary<long, Tuple<QueryState, QueryState>> m_rgQueryStates =
new Dictionary<long, Tuple<QueryState, QueryState>>();
214 object m_objSync =
new object();
222 m_rgQueryStates.Add(0,
null);
230 foreach (KeyValuePair<
long, Tuple<QueryState, QueryState>> kv
in m_rgQueryStates)
232 kv.Value.Item1.Dispose();
233 kv.Value.Item2.Dispose();
236 m_rgQueryStates.Clear();
251 if (m_rgQueryStates.Count > 0)
252 lHandle = m_rgQueryStates.Max(p => p.Key) + 1;
254 m_rgQueryStates.Add(lHandle,
new Tuple<QueryState, QueryState>(training, testing));
272 if (m_rgQueryStates.ContainsKey(lHandle))
274 m_rgQueryStates[lHandle].Item1.Dispose();
275 m_rgQueryStates[lHandle].Item2.Dispose();
276 m_rgQueryStates.Remove(lHandle);
292 throw new Exception(
"Invalid training QueryState handle, cannot = 0.");
296 return m_rgQueryStates[lHandle].Item1;
308 throw new Exception(
"Invalid testing QueryState handle, cannot = 0.");
312 return m_rgQueryStates[lHandle].Item2;
324 foreach (KeyValuePair<
long, Tuple<QueryState, QueryState>> kv
in m_rgQueryStates)
326 if (kv.Value !=
null)
327 kv.Value.Item1.Reload(rgItems);
340 foreach (KeyValuePair<
long, Tuple<QueryState, QueryState>> kv
in m_rgQueryStates)
342 if (kv.Value !=
null)
343 kv.Value.Item2.Reload(rgItems);
The SimpleDatum class holds a data input within host memory.
int Boost
Get/set the boost for this data.
int Label
Return the known label of the data.
The LabelDescriptor class describes a single label.
List< LabelDescriptor > Labels
Get/set the list of LabelDescriptors that describe the labels used by the data items.
The MasterIndexes stores the indexes that define the index structure of the data source data.
LabelIndex m_rgLabelsBoosted
Specifies the list of all boosted images listed by label where each label contains an index into all ...
int LabelCount
Returns the number of labels.
void SetIndex(Index idx, int? nLabel=null, bool bBoosted=false)
Set a given index based on the criteria.
int LoadLimit
Returns the load limit set during initialization.
SourceDescriptor m_src
Specifies the data source descriptor.
LabelIndex m_rgLabels
Specifies the list of images listed by label where each label contains an index into all images with ...
Index GetIndex(int? nLabel=null, bool bBoosted=false)
Returns the Index matching the criteria.
The QueryStateCollection manages all query states used by matching the QueryState handles with the Qu...
void ReIndexTraining(List< DbItem > rgItems)
Relabels the training QueryState based on the DbItems.
QueryState GetTrainingState(long lHandle)
Returns the QueryState used with thet Training data source.
bool FreeQueryState(long lHandle)
Free the QueryStates associated with the handle and remove it from the handle list.
void Dispose()
Releases all resources.
QueryStateCollection()
The constructor.
QueryState GetTestingState(long lHandle)
Returns the QueryState used with thet Testing data source.
void ReIndexTesting(List< DbItem > rgItems)
Relabels the testing QueryState based on the DbItems.
long CreateNewState(QueryState training, QueryState testing)
Create a new QueryState handle based on the QueryStates passed to this function.
Initially the QueryState is copied from the MasterIndexes and during each query is altered by removin...
Dictionary< int, ulong > GetQueryLabelCounts()
Returns the query label counts.
int? GetNextImage(DB_ITEM_SELECTION_METHOD imgSel, int? nLabel, int nDirectIdx)
Returns the next image in the Index set based on the selection criteria.
override? int GetNextImage(Index.SELECTION_TYPE type, int? nLabel=null, bool bBoosted=false, int nDirectIdx=-1)
Returns the next image in the Index set based on the selection criteria.
void UpdateStats(SimpleDatum sd)
Update the label stats.
override? int GetNextLabel(Index.SELECTION_TYPE type, bool bBoosted=false)
Returns the next label in the Index set selected based on the selection criteria.
int? GetNextLabel(DB_LABEL_SELECTION_METHOD lblSel)
Returns the next label in the Index set selected based on the selection criteria.
QueryState(MasterIndexes master, bool bUseUniqueLabelIndexes=true, bool bUseUniqueImageIndexes=true, IMGDB_SORT sort=IMGDB_SORT.BYIDX)
The constructor.
string GetQueryBoostHitPercentsAsText()
Returns the number of times each boosted image vs. non boosted images are hit.
string GetQueryLabelEpochsAsText()
Returns the number of epochs each label has experienced.
string GetQueryLabelHitPercentsAsText()
Returns the number of times each label is hit.
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.
DB_ITEM_SELECTION_METHOD
Defines the item (e.g., image or temporal item) selection method.
IMGDB_SORT
Defines the sorting method.
DB_LABEL_SELECTION_METHOD
Defines the label selection method.
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-...