MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DataTemporalParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.tft
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 string m_strSource = null;
22 uint m_nBatchSize;
23 uint m_nNumHistoricalSteps;
24 uint m_nNumFutureSteps;
25 SOURCE_TYPE m_srcType = SOURCE_TYPE.PATH_NPY_FILE;
26 Phase? m_forcedPhase = null;
27 double m_dfMaxLoadPercent = 1;
28 uint m_nChunkCount = 1024;
29 int m_nDripRefreshRate = 0;
30 uint? m_nSeed = null;
31 bool m_bShuffleData = true;
32 bool m_bOutputTargetHistorical = false;
33 bool m_bEnableDebugOutput = false;
34 string m_strDebugOutputPath = null;
35
39 public enum SOURCE_TYPE
40 {
60 PATH_NPY_FILE,
64 SQL_DB
65 }
66
69 {
70 }
71
79 {
80 get { return m_bEnableDebugOutput; }
81 set { m_bEnableDebugOutput = value; }
82 }
83
87 public string debug_output_path
88 {
89 get { return m_strDebugOutputPath; }
90 set { m_strDebugOutputPath = value; }
91 }
92
96 [Description("Optionally, specifies to output a top containing the target historical data.")]
98 {
99 get { return m_bOutputTargetHistorical; }
100 set { m_bOutputTargetHistorical = value; }
101 }
102
106 [Description("Optionally, specifies the phase to use when loading data.")]
108 {
109 get { return m_forcedPhase; }
110 set { m_forcedPhase = value; }
111 }
112
116 [Description("Specifies to randomly select from the data (default = true).")]
117 public bool shuffle_data
118 {
119 get { return m_bShuffleData; }
120 set { m_bShuffleData = value; }
121 }
122
129 [Description("Specifies the number of items to load per cycle when background loading (default = 1024).")]
130 public uint chunk_count
131 {
132 get { return m_nChunkCount; }
133 set { m_nChunkCount = value; }
134 }
135
139 [Description("Specifies the random seed used to shuffle the data. When not specified, the default seed is used.")]
140 public uint? seed
141 {
142 get { return m_nSeed; }
143 set { m_nSeed = value; }
144 }
145
149 [Description("Specifies the maximum percent of data rows to load (default = 1.0 = 100%).")]
150 public double max_load_percent
151 {
152 get { return m_dfMaxLoadPercent; }
153 set { m_dfMaxLoadPercent = value; }
154 }
155
159 [Description("Specifies rate the drip refresh occurs in seconds (default = 0, disabled).")]
161 {
162 get { return m_nDripRefreshRate; }
163 set { m_nDripRefreshRate= value; }
164 }
165
169 [Description("Specifies the type of source data.")]
171 {
172 get { return m_srcType; }
173 set { m_srcType = value; }
174 }
175
182 [Description("Specifies the data source.")]
183 public string source
184 {
185 get { return m_strSource; }
186 set { m_strSource = value; }
187 }
188
192 [Description("Specifies the batch size the data.")]
193 public virtual uint batch_size
194 {
195 get { return m_nBatchSize; }
196 set { m_nBatchSize = value; }
197 }
198
202 [Description("Specifies the number of historical steps.")]
204 {
205 get { return m_nNumHistoricalSteps; }
206 set { m_nNumHistoricalSteps = value; }
207 }
208
212 [Description("Specifies the number of future steps.")]
214 {
215 get { return m_nNumFutureSteps; }
216 set { m_nNumFutureSteps = value; }
217 }
218
220 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
221 {
222 RawProto proto = RawProto.Parse(br.ReadString());
224
225 if (!bNewInstance)
226 Copy(p);
227
228 return p;
229 }
230
232 public override void Copy(LayerParameterBase src)
233 {
235
236 m_srcType = p.source_type;
237 m_strSource = p.source;
238 m_nBatchSize = p.batch_size;
239
240 m_nNumHistoricalSteps = p.num_historical_steps;
241 m_nNumFutureSteps = p.num_future_steps;
242
243 m_dfMaxLoadPercent = p.max_load_percent;
244 m_nDripRefreshRate = p.drip_refresh_rate_in_sec;
245 m_nSeed = p.seed;
246 m_nChunkCount = p.chunk_count;
247 m_bShuffleData = p.shuffle_data;
248 m_forcedPhase = p.forced_phase;
249 m_bOutputTargetHistorical = p.output_target_historical;
250
251 m_bEnableDebugOutput = p.enable_debug_output;
252 m_strDebugOutputPath = p.debug_output_path;
253 }
254
256 public override LayerParameterBase Clone()
257 {
259 p.Copy(this);
260 return p;
261 }
262
268 public override RawProto ToProto(string strName)
269 {
270 RawProtoCollection rgChildren = new RawProtoCollection();
271
272 rgChildren.Add("batch_size", batch_size.ToString());
273 rgChildren.Add("source", source);
274 rgChildren.Add("source_type", source_type.ToString());
275
276 rgChildren.Add("num_historical_steps", num_historical_steps.ToString());
277 rgChildren.Add("num_future_steps", num_future_steps.ToString());
278
279 rgChildren.Add("max_load_percent", max_load_percent.ToString());
280 rgChildren.Add("drip_refresh_rate_in_sec", drip_refresh_rate_in_sec.ToString());
281 rgChildren.Add("chunk_count", chunk_count.ToString());
282 rgChildren.Add("shuffle_data", shuffle_data.ToString());
283 rgChildren.Add("output_target_historical", output_target_historical.ToString());
284
285 rgChildren.Add("enable_debug_output", enable_debug_output.ToString());
286 rgChildren.Add("debug_output_path", debug_output_path);
287
288 if (seed.HasValue)
289 rgChildren.Add("seed", seed.Value.ToString());
290
291 if (forced_phase.HasValue)
292 rgChildren.Add("forced_phase", forced_phase.Value.ToString());
293
294 return new RawProto(strName, "", rgChildren);
295 }
296
303 {
304 string strVal;
306
307 if ((strVal = rp.FindValue("batch_size")) != null)
308 p.batch_size = uint.Parse(strVal);
309
310 if ((strVal = rp.FindValue("source")) != null)
311 p.source = strVal;
312
313 if ((strVal = rp.FindValue("source_type")) != null)
314 {
315 if (strVal == SOURCE_TYPE.PATH_NPY_FILE.ToString())
316 p.source_type = SOURCE_TYPE.PATH_NPY_FILE;
317 else if (strVal == SOURCE_TYPE.SQL_DB.ToString())
318 p.source_type = SOURCE_TYPE.SQL_DB;
319 else
320 throw new Exception("Unknown source_type '" + strVal + "'!");
321 }
322
323 if ((strVal = rp.FindValue("num_historical_steps")) != null)
324 p.num_historical_steps = uint.Parse(strVal);
325
326 if ((strVal = rp.FindValue("num_future_steps")) != null)
327 p.num_future_steps = uint.Parse(strVal);
328
329 if ((strVal = rp.FindValue("max_load_percent")) != null)
330 p.max_load_percent = double.Parse(strVal);
331
332 if ((strVal = rp.FindValue("drip_refresh_rate_in_sec")) != null)
333 p.drip_refresh_rate_in_sec = int.Parse(strVal);
334
335 if ((strVal = rp.FindValue("chunk_count")) != null)
336 p.chunk_count = uint.Parse(strVal);
337
338 if (p.chunk_count == 0)
339 p.chunk_count = 1;
340
341 if ((strVal = rp.FindValue("seed")) != null)
342 p.seed = uint.Parse(strVal);
343
344 if ((strVal = rp.FindValue("shuffle_data")) != null)
345 p.shuffle_data = bool.Parse(strVal);
346
347 if ((strVal = rp.FindValue("forced_phase")) != null)
348 {
349 if (strVal == Phase.TRAIN.ToString())
350 p.forced_phase = Phase.TRAIN;
351 else if (strVal == Phase.TEST.ToString())
352 p.forced_phase = Phase.TEST;
353 else if (strVal == Phase.RUN.ToString())
354 p.forced_phase = Phase.RUN;
355 else
356 throw new Exception("Unknown forced_phase '" + strVal + "'!");
357 }
358
359 if ((strVal = rp.FindValue("output_target_historical")) != null)
360 p.output_target_historical = bool.Parse(strVal);
361
362 if ((strVal = rp.FindValue("enable_debug_output")) != null)
363 p.enable_debug_output = bool.Parse(strVal);
364
365 if ((strVal = rp.FindValue("debug_output_path")) != null)
366 p.debug_output_path = strVal;
367
368 return p;
369 }
370 }
371}
The RawProtoCollection class is a list of RawProto objects.
void Add(RawProto p)
Adds a RawProto to the collection.
The RawProto class is used to parse and output Google prototxt file data.
Definition: RawProto.cs:17
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
Definition: RawProto.cs:306
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the DataTemporalLayer (used in TFT models).
bool shuffle_data
Specifies to randomly select from the data (default = true).
SOURCE_TYPE
Defines the type of source data.
bool enable_debug_output
Optionally, specifies to output debug information (slower) on each pass.
string debug_output_path
Specifies the debug output path where debug images are placed when enable_debug_output = true.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
virtual uint batch_size
Specifies the batch size of the data.
int drip_refresh_rate_in_sec
Specifies rate the drip refresh occurs in seconds (default = 0, disabled).
uint num_historical_steps
Specifies the number of historical steps
uint num_future_steps
Specifies the number of future steps
double max_load_percent
Specifies the maximum percent of data rows to load (default = 1.0 = 100%).
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Phase? forced_phase
Optionally, specifies the phase to use when loading data.
static DataTemporalParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
string source
Specifies the data source.
uint chunk_count
Specifies the number of items to load per cycle when background loading (default = 1024).
DataTemporalParameter()
Constructor for the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
bool output_target_historical
Optionally, specifies to output a top containing the target historical data.
uint? seed
Specifies the random seed used to shuffle the data. When not specified, the default seed is used.
SOURCE_TYPE source_type
Specifies the type of source data.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
Phase
Defines the Phase under which to run a Net.
Definition: Interfaces.cs:61
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12