MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DataSet.cs
1using MyCaffe.basecode;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading;
8using System.Threading.Tasks;
9
10namespace MyCaffe.db.temporal
11{
15 [Serializable]
16 public class DataSet
17 {
18 Log m_log;
19 CryptoRandom m_random = new CryptoRandom();
22 Dictionary<int, TemporalSet> m_rgTemporalSets = new Dictionary<int, TemporalSet>();
23 Dictionary<Phase, TemporalSet> m_rgTemporalSetsEx = new Dictionary<Phase, TemporalSet>();
24
31 {
32 m_ds = ds;
33 m_log = log;
34 }
35
39 public void CleanUp()
40 {
41 foreach (KeyValuePair<int, TemporalSet> kv in m_rgTemporalSets)
42 {
43 if (kv.Value != null)
44 kv.Value.CleanUp();
45 }
46
47 m_rgTemporalSets.Clear();
48 m_rgTemporalSetsEx.Clear();
49 }
50
55 {
56 get { return m_ds; }
57 }
58
65 {
66 if (m_rgTemporalSetsEx.ContainsKey(phase))
67 return m_rgTemporalSetsEx[phase];
68
69 return null;
70 }
71
78 {
79 if (m_rgTemporalSets.ContainsKey(nSourceID))
80 return m_rgTemporalSets[nSourceID];
81
82 return null;
83 }
84
91 public double GetLoadPercent(out double dfTraining, out double dfTesting)
92 {
93 dfTraining = 0;
94
95 if (m_rgTemporalSetsEx.ContainsKey(Phase.TRAIN))
96 dfTraining = m_rgTemporalSetsEx[Phase.TRAIN].LoadPercent;
97
98 dfTesting = 0;
99
100 if (m_rgTemporalSetsEx.ContainsKey(Phase.TEST))
101 dfTesting = m_rgTemporalSetsEx[Phase.TEST].LoadPercent;
102
103 return (dfTraining + dfTesting) / 2.0;
104 }
105
118 public bool Load(DB_LOAD_METHOD loadMethod, int nLoadLimit, double dfReplacementPct, int nRefreshUpdateMs, bool bNormalizedData, int nHistoricalSteps, int nFutureSteps, int nChunks, EventWaitHandle evtCancel)
119 {
120 List<TemporalSet> rgInit = new List<TemporalSet>();
121
122 if (!m_rgTemporalSets.ContainsKey(m_ds.TrainingSource.ID))
123 {
124 TemporalSet ts = new TemporalSet(m_log, m_db, m_ds.TrainingSource, loadMethod, nLoadLimit, dfReplacementPct, nRefreshUpdateMs, m_random, nHistoricalSteps, nFutureSteps, nChunks);
125 m_rgTemporalSets.Add(m_ds.TrainingSource.ID, ts);
126 m_rgTemporalSetsEx.Add(Phase.TRAIN, ts);
127 rgInit.Add(ts);
128 }
129
130 if (!m_rgTemporalSets.ContainsKey(m_ds.TestingSource.ID))
131 {
132 TemporalSet ts = new TemporalSet(m_log, m_db, m_ds.TestingSource, loadMethod, nLoadLimit, dfReplacementPct, nRefreshUpdateMs, m_random, nHistoricalSteps, nFutureSteps, nChunks);
133 m_rgTemporalSets.Add(m_ds.TestingSource.ID, ts);
134 m_rgTemporalSetsEx.Add(Phase.TEST, ts);
135 rgInit.Add(ts);
136 }
137
138 foreach (TemporalSet ts1 in rgInit)
139 {
140 if (!ts1.Initialize(bNormalizedData, evtCancel))
141 return false;
142 }
143
144 return true;
145 }
146
152 public bool WaitForLoadingToComplete(AutoResetEvent evtCancel)
153 {
154 foreach (KeyValuePair<int, TemporalSet> kv in m_rgTemporalSets)
155 {
156 if (!kv.Value.WaitForLoadingToComplete(evtCancel))
157 return false;
158 }
159
160 return true;
161 }
162 }
163}
The CryptoRandom is a random number generator that can use either the standard .Net Random objec or t...
Definition: CryptoRandom.cs:14
The Log class provides general output in text form.
Definition: Log.cs:13
int ID
Get/set the database ID of the item.
The DatasetDescriptor class describes a dataset which contains both a training data source and testin...
SourceDescriptor TrainingSource
Get/set the training data source.
SourceDescriptor TestingSource
Get/set the testing data source.
The DataSet class loads the training and testing data.
Definition: DataSet.cs:17
void CleanUp()
Remove all data for the dataset from memory.
Definition: DataSet.cs:39
DatasetDescriptor Dataset
Return the dataset descriptor.
Definition: DataSet.cs:55
DataSet(DatasetDescriptor ds, Log log)
The constructor.
Definition: DataSet.cs:30
double GetLoadPercent(out double dfTraining, out double dfTesting)
Return the load percentage for the dataset.
Definition: DataSet.cs:91
bool WaitForLoadingToComplete(AutoResetEvent evtCancel)
Wait for the loading to complete.
Definition: DataSet.cs:152
TemporalSet GetTemporalSetBySourceID(int nSourceID)
Returns the temporal set for the specified source ID.
Definition: DataSet.cs:77
TemporalSet GetTemporalSetByPhase(Phase phase)
Returns the temporal set for the specified phase.
Definition: DataSet.cs:64
bool Load(DB_LOAD_METHOD loadMethod, int nLoadLimit, double dfReplacementPct, int nRefreshUpdateMs, bool bNormalizedData, int nHistoricalSteps, int nFutureSteps, int nChunks, EventWaitHandle evtCancel)
Load the training and testing data.
Definition: DataSet.cs:118
The DatabaseTemporal is used to manage all temporal specific database objects.
The TemporalSet manages a set of temporal data for a given data source.
Definition: TemporalSet.cs:21
bool Initialize(bool bNormalizedData, EventWaitHandle evtCancel)
Load the data based on the data load method.
Definition: TemporalSet.cs:129
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.
Definition: Annotation.cs:12
DB_LOAD_METHOD
Defines how to laod the items into the in-memory database.
Definition: Interfaces.cs:154
Phase
Defines the Phase under which to run a Net.
Definition: Interfaces.cs:61
The MyCaffe.db.temporal namespace contains all classes used to create the MyCaffeTemporalDatabase in-...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12