MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SettingsCaffe.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Runtime.Serialization;
6
7namespace MyCaffe.basecode
8{
12 [Serializable]
13 public class SettingsCaffe : ISerializable
14 {
15 DB_VERSION m_imgDbVersion = DB_VERSION.DEFAULT;
16 bool m_bEnableLabelBalancing = false;
17 bool m_bEnableLabelBoosting = false;
18 bool m_bEnableRandomInputSelection = true;
19 bool m_bEnablePairInputSelection = false;
20 bool m_bUseTrainingSourceForTesting = false;
21 bool m_bVerifyDatasetOnLoad = false;
22 double m_dfSuperBoostProbability = 0.0;
23 int m_nMaximumIterationOverride = -1;
24 int m_nTestingIterationOverride = -1;
25 string m_strDefaultModelGroup = "";
26 string m_strGpuIds = "0";
27 DB_LOAD_METHOD m_dbLoadMethod = DB_LOAD_METHOD.LOAD_ON_DEMAND;
28 int m_nDbLoadLimit = 0;
29 int m_nAutoRefreshScheduledUpdateInMs = 0;
30 double m_dfAutoRefreshScheduledReplacementPct = 0;
31 bool m_bItemDbLoadDataCriteria = false;
32 bool m_bItemDbLoadDebugData = false;
33 SNAPSHOT_WEIGHT_UPDATE_METHOD m_snapshotWeightUpdateMethod = SNAPSHOT_WEIGHT_UPDATE_METHOD.FAVOR_ACCURACY;
34 SNAPSHOT_LOAD_METHOD m_snapshotLoadMethod = SNAPSHOT_LOAD_METHOD.STATE_BEST_ACCURACY;
35 bool m_bSkipMeanCheck = false;
36
41 {
42 }
43
48 {
49 m_imgDbVersion = s.m_imgDbVersion;
50 m_bEnableLabelBalancing = s.m_bEnableLabelBalancing;
51 m_bEnableLabelBoosting = s.m_bEnableLabelBoosting;
52 m_bEnableRandomInputSelection = s.m_bEnableRandomInputSelection;
53 m_bEnablePairInputSelection = s.m_bEnablePairInputSelection;
54 m_bUseTrainingSourceForTesting = s.m_bUseTrainingSourceForTesting;
55 m_bVerifyDatasetOnLoad = s.m_bVerifyDatasetOnLoad;
56 m_dfSuperBoostProbability = s.m_dfSuperBoostProbability;
57 m_nMaximumIterationOverride = s.m_nMaximumIterationOverride;
58 m_nTestingIterationOverride = s.m_nTestingIterationOverride;
59 m_strDefaultModelGroup = s.m_strDefaultModelGroup;
60 m_strGpuIds = s.m_strGpuIds;
61 m_dbLoadMethod = s.m_dbLoadMethod;
62 m_nDbLoadLimit = s.m_nDbLoadLimit;
63 m_nAutoRefreshScheduledUpdateInMs = s.m_nAutoRefreshScheduledUpdateInMs;
64 m_dfAutoRefreshScheduledReplacementPct = s.m_dfAutoRefreshScheduledReplacementPct;
65 m_bItemDbLoadDataCriteria = s.m_bItemDbLoadDataCriteria;
66 m_bItemDbLoadDebugData = s.m_bItemDbLoadDebugData;
67 m_snapshotWeightUpdateMethod = s.m_snapshotWeightUpdateMethod;
68 m_snapshotLoadMethod = s.m_snapshotLoadMethod;
69 m_bSkipMeanCheck = s.m_bSkipMeanCheck;
70 }
71
77 public SettingsCaffe(SerializationInfo info, StreamingContext context)
78 {
79 m_imgDbVersion = (DB_VERSION)getInt(info, "ImageDbVersion", (int)m_imgDbVersion);
80 m_bEnableLabelBalancing = getBool(info, "bEnableLabelBalancing", m_bEnableLabelBalancing);
81 m_bEnableLabelBoosting = getBool(info, "bEnableLabelBoosting", m_bEnableLabelBoosting);
82 m_bEnableRandomInputSelection = getBool(info, "bEnableRandomInputSelection", m_bEnableRandomInputSelection);
83 m_bEnablePairInputSelection = getBool(info, "bEnablePairInputSelection", m_bEnablePairInputSelection);
84 m_bUseTrainingSourceForTesting = getBool(info, "bUseTrainingSourceForTesting", m_bUseTrainingSourceForTesting);
85 m_bVerifyDatasetOnLoad = getBool(info, "bVerifyDatasetOnLoad", m_bVerifyDatasetOnLoad);
86 m_dfSuperBoostProbability = getDouble(info, "dfSuperBoostProbability", m_dfSuperBoostProbability);
87 m_nMaximumIterationOverride = getInt(info, "nMaximumIterationOverride", m_nMaximumIterationOverride);
88 m_nTestingIterationOverride = getInt(info, "nTestingIterationOverride", m_nTestingIterationOverride);
89 m_strDefaultModelGroup = info.GetString("strDefaultModelGroup");
90 m_strGpuIds = getString(info, "strGpuIds", m_strGpuIds);
91 m_dbLoadMethod = (DB_LOAD_METHOD)getInt(info, "ImageDbLoadMethod", (int)m_dbLoadMethod);
92 m_nDbLoadLimit = getInt(info, "ImageDbLoadLimit", m_nDbLoadLimit);
93 m_nAutoRefreshScheduledUpdateInMs = getInt(info, "ImageDbAutoRefreshScheduledUpdateInMs", m_nAutoRefreshScheduledUpdateInMs);
94 m_dfAutoRefreshScheduledReplacementPct = getDouble(info, "ImageDbAutoRefreshReplacementPct", m_dfAutoRefreshScheduledReplacementPct);
95 m_bItemDbLoadDataCriteria = getBool(info, "ImageDbLoadDataCriteria", m_bItemDbLoadDataCriteria);
96 m_bItemDbLoadDebugData = getBool(info, "ImageDbLoadDebugData", m_bItemDbLoadDebugData);
97 m_snapshotWeightUpdateMethod = (SNAPSHOT_WEIGHT_UPDATE_METHOD)getInt(info, "SnapshotWeightUpdateMethod", (int)m_snapshotWeightUpdateMethod);
98 m_snapshotLoadMethod = (SNAPSHOT_LOAD_METHOD)getInt(info, "SnapshotLoadMethod", (int)m_snapshotLoadMethod);
99 m_bSkipMeanCheck = getBool(info, "SkipMeanCheck", m_bSkipMeanCheck);
100 }
101
102 private bool getBool(SerializationInfo info, string str, bool bDefault)
103 {
104 try
105 {
106 return info.GetBoolean(str);
107 }
108 catch
109 {
110 return bDefault;
111 }
112 }
113
114 private double getDouble(SerializationInfo info, string str, double dfDefault)
115 {
116 try
117 {
118 return info.GetDouble(str);
119 }
120 catch
121 {
122 return dfDefault;
123 }
124 }
125
126 private string getString(SerializationInfo info, string str, string strDefault)
127 {
128 try
129 {
130 return info.GetString(str);
131 }
132 catch
133 {
134 return strDefault;
135 }
136 }
137
138 private int getInt(SerializationInfo info, string str, int nDefault)
139 {
140 try
141 {
142 return info.GetInt32(str);
143 }
144 catch
145 {
146 return nDefault;
147 }
148 }
149
155 public void GetObjectData(SerializationInfo info, StreamingContext context)
156 {
157 info.AddValue("ImageDbVersion", (int)m_imgDbVersion);
158 info.AddValue("bEnableLabelBalancing", m_bEnableLabelBalancing);
159 info.AddValue("bEnableLabelBoosting", m_bEnableLabelBoosting);
160 info.AddValue("bEnableRandomInputSelection", m_bEnableRandomInputSelection);
161 info.AddValue("bEnablePairInputSelection", m_bEnablePairInputSelection);
162 info.AddValue("bUseTrainingSourceForTesting", m_bUseTrainingSourceForTesting);
163 info.AddValue("bVerifyDatasetOnLoad", m_bVerifyDatasetOnLoad);
164 info.AddValue("dfSuperBoostProbability", m_dfSuperBoostProbability);
165 info.AddValue("nMaximumIterationOverride", m_nMaximumIterationOverride);
166 info.AddValue("nTestingIterationOverride", m_nTestingIterationOverride);
167 info.AddValue("strDefaultModelGroup", m_strDefaultModelGroup);
168 info.AddValue("strGpuIds", m_strGpuIds);
169 info.AddValue("ImageDbLoadMethod", (int)m_dbLoadMethod);
170 info.AddValue("ImageDbLoadLimit", m_nDbLoadLimit);
171 info.AddValue("ImageDbAutoRefreshScheduledUpdateInMs", m_nAutoRefreshScheduledUpdateInMs);
172 info.AddValue("ImageDbAutoRefreshReplacementPct", m_dfAutoRefreshScheduledReplacementPct);
173 info.AddValue("ImageDbLoadDataCriteria", m_bItemDbLoadDataCriteria);
174 info.AddValue("ImageDbLoadDebugData", m_bItemDbLoadDebugData);
175 info.AddValue("SnapshotWeightUpdateMethod", (int)m_snapshotWeightUpdateMethod);
176 info.AddValue("SnapshotLoadMethod", (int)m_snapshotLoadMethod);
177 info.AddValue("SkipMeanCheck", m_bSkipMeanCheck);
178 }
179
185 {
187
188 s.m_imgDbVersion = m_imgDbVersion;
189 s.m_bEnableLabelBalancing = m_bEnableLabelBalancing;
190 s.m_bEnableLabelBoosting = m_bEnableLabelBoosting;
191 s.m_bEnableRandomInputSelection = m_bEnableRandomInputSelection;
192 s.m_bEnablePairInputSelection = m_bEnablePairInputSelection;
193 s.m_bUseTrainingSourceForTesting = m_bUseTrainingSourceForTesting;
194 s.m_bVerifyDatasetOnLoad = m_bVerifyDatasetOnLoad;
195 s.m_dfSuperBoostProbability = m_dfSuperBoostProbability;
196 s.m_nMaximumIterationOverride = m_nMaximumIterationOverride;
197 s.m_nTestingIterationOverride = m_nTestingIterationOverride;
198 s.m_strDefaultModelGroup = m_strDefaultModelGroup;
199 s.m_strGpuIds = m_strGpuIds;
200 s.m_dbLoadMethod = m_dbLoadMethod;
201 s.m_nDbLoadLimit = m_nDbLoadLimit;
202 s.m_nAutoRefreshScheduledUpdateInMs = m_nAutoRefreshScheduledUpdateInMs;
203 s.m_dfAutoRefreshScheduledReplacementPct = m_dfAutoRefreshScheduledReplacementPct;
204 s.m_bItemDbLoadDataCriteria = m_bItemDbLoadDataCriteria;
205 s.m_bItemDbLoadDebugData = m_bItemDbLoadDebugData;
206 s.m_snapshotWeightUpdateMethod = m_snapshotWeightUpdateMethod;
207 s.m_snapshotLoadMethod = m_snapshotLoadMethod;
208 s.m_bSkipMeanCheck = m_bSkipMeanCheck;
209
210 return s;
211 }
212
217 {
218 get { return m_bVerifyDatasetOnLoad; }
219 set { m_bVerifyDatasetOnLoad = value; }
220 }
221
226 {
227 get { return m_imgDbVersion; }
228 set { m_imgDbVersion = value; }
229 }
230
236 {
237 get { return m_bEnableLabelBalancing; }
238 set { m_bEnableLabelBalancing = value; }
239 }
240
246 {
247 get { return m_bEnableLabelBoosting; }
248 set { m_bEnableLabelBoosting = value; }
249 }
250
256 {
257 get { return m_bEnableRandomInputSelection; }
258 set { m_bEnableRandomInputSelection = value; }
259 }
260
267 {
268 get { return m_bEnablePairInputSelection; }
269 set { m_bEnablePairInputSelection = value; }
270 }
271
276 {
277 get { return m_bUseTrainingSourceForTesting; }
278 set { m_bUseTrainingSourceForTesting = value; }
279 }
280
285 {
286 get { return m_dfSuperBoostProbability; }
287 set { m_dfSuperBoostProbability = value; }
288 }
289
294 {
295 get { return m_nMaximumIterationOverride; }
296 set { m_nMaximumIterationOverride = value; }
297 }
298
303 {
304 get { return m_nTestingIterationOverride; }
305 set { m_nTestingIterationOverride = value; }
306 }
307
311 public string DefaultModelGroup
312 {
313 get { return m_strDefaultModelGroup; }
314 set { m_strDefaultModelGroup = value; }
315 }
316
324 public string GpuIds
325 {
326 get { return m_strGpuIds; }
327 set { m_strGpuIds = value; }
328 }
329
334 {
335 get { return m_dbLoadMethod; }
336 set { m_dbLoadMethod = value; }
337 }
338
342 public int DbLoadLimit
343 {
344 get { return m_nDbLoadLimit; }
345 set
346 {
347 if (value == 0 && m_nDbLoadLimit != 0)
348 {
349 m_nAutoRefreshScheduledUpdateInMs = 0;
350 m_dfAutoRefreshScheduledReplacementPct = 0;
351 }
352 else if (value != 0 && m_nDbLoadLimit == 0)
353 {
354 m_nAutoRefreshScheduledUpdateInMs = 10000;
355 m_dfAutoRefreshScheduledReplacementPct = 0.3;
356 }
357
358 m_nDbLoadLimit = value;
359 }
360 }
361
366 {
367 get { return m_nAutoRefreshScheduledUpdateInMs; }
368 set { m_nAutoRefreshScheduledUpdateInMs = value; }
369 }
370
375 {
376 get { return m_dfAutoRefreshScheduledReplacementPct; }
377 set { m_dfAutoRefreshScheduledReplacementPct = value; }
378 }
379
384 {
385 get { return m_bItemDbLoadDataCriteria; }
386 set { m_bItemDbLoadDataCriteria = value; }
387 }
388
393 {
394 get { return m_bItemDbLoadDebugData; }
395 set { m_bItemDbLoadDebugData = value; }
396 }
397
402 {
403 get { return m_snapshotWeightUpdateMethod; }
404 set { m_snapshotWeightUpdateMethod = value; }
405 }
406
411 {
412 get { return m_snapshotLoadMethod; }
413 set { m_snapshotLoadMethod = value; }
414 }
415
419 public bool SkipMeanCheck
420 {
421 get { return m_bSkipMeanCheck; }
422 set { m_bSkipMeanCheck = value; }
423 }
424 }
425}
The SettingsCaffe defines the settings used by the MyCaffe CaffeControl.
SNAPSHOT_WEIGHT_UPDATE_METHOD SnapshotWeightUpdateMethod
Get/set the snapshot update method.
bool EnableRandomInputSelection
Get/set random image selection. When enabled, images are randomly selected from the entire set,...
SNAPSHOT_LOAD_METHOD SnapshotLoadMethod
Get/set the snapshot load method.
double DbAutoRefreshScheduledReplacementPercent
Get/set the automatic refresh scheduled update replacement percentage used on refresh (default = 0....
int DbLoadLimit
Get/set the image database load limit.
SettingsCaffe Clone()
Returns a copy of the SettingsCaffe object.
bool EnableLabelBoosting
DEPRECIATED: Get/set label boosting. When using Label boosting, images are selected from boosted labe...
double SuperBoostProbability
Get/set the superboost probability used when selecting boosted images.
SettingsCaffe(SettingsCaffe s)
The SettingsCaffe constructor that copies another SettingsCaffe instance.
DB_LOAD_METHOD DbLoadMethod
Get/set the image database loading method.
bool UseTrainingSourceForTesting
Get/set whether or not to use the training datasource when testing.
bool EnablePairInputSelection
Get/set pair image selection. When using pair selection, images are queried in pairs where the first ...
bool ItemDbLoadDebugData
Specifies whether or not to load the debug data from file (default = false).
string GpuIds
Get/set the default GPU ID's to use when training.
int MaximumIterationOverride
Get/set the maximum iteration override. When set, this overrides the training iterations specified in...
int DbAutoRefreshScheduledUpdateInMs
Get/set the automatic refresh scheduled udpate period (default = 10000, only applies when ImageDbLoad...
DB_VERSION DbVersion
Get/set the version of the MyCaffeImageDatabase to use.
bool ItemDbLoadDataCriteria
Specifies whether or not to load the image criteria data from file (default = false).
string DefaultModelGroup
Get/set the default model group to use.
int TestingIterationOverride
Get/set the testing iteration override. When set, this overrides the testing iterations specified in ...
bool SkipMeanCheck
Skip checking for the mean of the dataset - this is not recommended for if the mean does not exist,...
SettingsCaffe()
The SettingsCaffe constructor.
SettingsCaffe(SerializationInfo info, StreamingContext context)
The SettingsCaffe constructor used during deserialization.
bool VeriyDatasetOnLoad
Get/set whether or not to verify the dataset on load (only applies when using the LOAD_ALL loading me...
bool EnableLabelBalancing
Get/set label balancing. When enabled, first the label set is randomly selected and then the image is...
void GetObjectData(SerializationInfo info, StreamingContext context)
The GetObjectData is used during serialization.
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
DB_VERSION
Defines the image database version to use.
Definition: Interfaces.cs:397
SNAPSHOT_LOAD_METHOD
Defines the snapshot load method.
Definition: Interfaces.cs:204
SNAPSHOT_WEIGHT_UPDATE_METHOD
Defines the snapshot weight update method.
Definition: Interfaces.cs:181