2using System.Collections.Generic;
18 [TypeConverter(typeof(ExpandableObjectConverter))]
36 string m_strSource =
null;
38 DB m_backend =
DB.IMAGEDB;
40 bool? m_bEnableRandomSelection =
null;
41 bool? m_bEnablePairSelection =
null;
42 bool m_bDisplayTiming =
false;
44 bool m_bPrimaryData =
true;
45 string m_strSynchronizeWith =
null;
46 bool m_bSyncTarget =
false;
47 int m_nImagesPerBlob = 1;
48 bool m_bOutputAllLabels =
false;
49 bool m_bBalanceMatches =
true;
50 bool m_bOutputImageInfo =
false;
51 int m_nForcedPrimaryLabel = -1;
52 bool m_bEnableNoiseForNonMatch =
false;
54 bool m_bEnableDebugOutput =
false;
56 int m_nOneHotLabelEncodingSize = 0;
71 [Description(
"When used with the DATA parameter, specifies the data 'source' within the database. Some sources are used for training whereas others are used for testing. When used with the IMAGE_DATA parameter, the 'source' specifies the data 'source' file containing the list of image file names. Each dataset has both a training and testing data source.")]
74 get {
return m_strSource; }
75 set { m_strSource = value; }
81 [Description(
"Specifies the batch size of images to collect and train on each iteration of the network. NOTE: Setting the training netorks batch size >= to the testing net batch size will conserve memory by allowing the training net to share its gpu memory with the testing net.")]
84 get {
return m_nBatchSize; }
91 if (args.
Error !=
null)
106 [Description(
"Specifies the backend database type. Currently only the IMAGEDB database type is supported. However protofiles specifying the 'LMDB' backend are converted into the 'IMAGEDB' type.")]
109 get {
return m_backend; }
110 set { m_backend = value; }
117 [Description(
"Specifies the number of batches to prefetch to host memory. Increase this value if data access bandwidth varies.")]
120 get {
return m_nPrefetch; }
121 set { m_nPrefetch = value; }
127 [Category(
"Data Selection"), Description(
"Specifies whether or not to randomly query images from the data source. When false, images are queried in sequence which can often have poorer training results.")]
130 get {
return m_bEnableRandomSelection; }
131 set { m_bEnableRandomSelection = value; }
137 [Category(
"Data Selection"), Description(
"Specifies whether or not to select images in a pair sequence. When enabled, the first image queried is queried using the 'random' selection property, and then the second image queried is the image just after the first image queried (even if queried randomly).")]
140 get {
return m_bEnablePairSelection; }
141 set { m_bEnablePairSelection = value; }
147 [Category(
"Debugging"), Description(
"Specifies whether or not to display the timing of each image read.")]
150 get {
return m_bDisplayTiming; }
151 set { m_bDisplayTiming = value; }
157 [Category(
"Labels"), Description(
"Specifies the label type: SINGLE - the default which uses the 'Label' field, or MULTIPLE - which uses the 'DataCriteria' field.")]
160 get {
return m_labelType; }
161 set { m_labelType = value; }
167 [Category(
"Data Selection"), Description(
"Specifies whether or not this data is the primary dataset as opposed to the target dataset. By default, this is set to 'true'.")]
170 get {
return m_bPrimaryData; }
171 set { m_bPrimaryData = value; }
177 [Category(
"Synchronization"), Description(
"Specifies whether or not this is to be synchronized with another data layer as the target.")]
180 get {
return m_bSyncTarget; }
181 set { m_bSyncTarget = value; }
191 [Category(
"Synchronization"), Description(
"Specifies a secondary (target) dataset to synchronize with.")]
194 get {
return m_strSynchronizeWith; }
195 set { m_strSynchronizeWith = value; }
206 [Category(
"Multi-Image"), Description(
"Optionally, specifies the number of images to load into each blob channel, where each image is stacked on the channel dimension so a 3 channel item then becomes a 6 channel item when two images are stacked (default = 1).")]
209 get {
return m_nImagesPerBlob; }
210 set { m_nImagesPerBlob = value; }
216 [Category(
"Multi-Image"), Description(
"Optionally, specifies to output all labels for the stacked images instead of just the comparison. This setting only applies when 'images_per_blob' > 1 (default = false).")]
219 get {
return m_bOutputAllLabels; }
220 set { m_bOutputAllLabels = value; }
226 [Category(
"Multi-Image"), Description(
"Optionally, specifies to balance the matches by alternating between matching classes and non matching classes. This setting only applies when 'images_per_blob' > 1 (default = true).")]
229 get {
return m_bBalanceMatches; }
230 set { m_bBalanceMatches = value; }
236 [Category(
"Debugging"), Description(
"Optionally, specifies to output image information such as index and label which is only intended for debugging as it dramatically slows down processing. (default = false).")]
239 get {
return m_bOutputImageInfo; }
240 set { m_bOutputImageInfo = value; }
246 [Category(
"Multi-Image"), Description(
"Optionally, specifies to force the label of the primary image to this value. This setting only applies when 'images_per_blob' > 1 (default = -1 which causes this setting to be ignored).")]
249 get {
return m_nForcedPrimaryLabel; }
250 set { m_nForcedPrimaryLabel = value; }
256 [Category(
"Multi-Image"), Description(
"Optionally, specifies to use a noise generated image for the non matching image instead of an image from a different class. This setting only applies when 'images_per_blob' > 1 (default = false).")]
259 get {
return m_bEnableNoiseForNonMatch; }
260 set { m_bEnableNoiseForNonMatch = value; }
266 [Category(
"Multi-Image"), Description(
"Optionally, specifies the DataNoiseParameter that defines the noise used when 'enable_noise_for_nonmatch' = True. This setting only applies when 'images_per_blob' > 1.")]
269 get {
return m_dataNoiseParam; }
270 set { m_dataNoiseParam = value; }
276 [Category(
"Debugging"), Description(
"Optionally, specifies to output debug information about the data sent out through the top. (default = false).")]
279 get {
return m_bEnableDebugOutput; }
280 set { m_bEnableDebugOutput = value; }
286 [Category(
"Debugging"), Description(
"Optionally, specifies the parameters used when 'enable_debug_output' = True.")]
289 get {
return m_dataDebugParam; }
290 set { m_dataDebugParam = value; }
296 [Category(
"Labels"), Description(
"When greater than 0 (default = 0), labels are one-hot encoded to a vector of the one-hot label size (e.g., when size = 4: 3 -> 0 1 1 0; 4 -> 1 0 0 0)")]
299 get {
return m_nOneHotLabelEncodingSize; }
300 set { m_nOneHotLabelEncodingSize = value; }
304 public override object Load(
System.IO.BinaryReader br,
bool bNewInstance =
true)
319 m_strSource = p.m_strSource;
320 m_nBatchSize = p.m_nBatchSize;
321 m_backend = p.m_backend;
322 m_nPrefetch = p.m_nPrefetch;
323 m_bEnableRandomSelection = p.m_bEnableRandomSelection;
324 m_bEnablePairSelection = p.m_bEnablePairSelection;
325 m_bDisplayTiming = p.m_bDisplayTiming;
326 m_labelType = p.m_labelType;
327 m_bPrimaryData = p.m_bPrimaryData;
328 m_strSynchronizeWith = p.m_strSynchronizeWith;
329 m_bSyncTarget = p.m_bSyncTarget;
330 m_nImagesPerBlob = p.m_nImagesPerBlob;
331 m_bOutputAllLabels = p.m_bOutputAllLabels;
332 m_bBalanceMatches = p.m_bBalanceMatches;
333 m_bOutputImageInfo = p.m_bOutputImageInfo;
334 m_bEnableNoiseForNonMatch = p.m_bEnableNoiseForNonMatch;
335 m_dataNoiseParam.
Copy(p.m_dataNoiseParam);
336 m_bEnableDebugOutput = p.m_bEnableDebugOutput;
337 m_dataDebugParam.
Copy(p.m_dataDebugParam);
338 m_nForcedPrimaryLabel = p.m_nForcedPrimaryLabel;
339 m_nOneHotLabelEncodingSize = p.m_nOneHotLabelEncodingSize;
359 rgChildren.
Add(
"source",
"\"" +
source +
"\"");
361 rgChildren.
Add(
"backend",
backend.ToString());
381 rgChildren.
Add(
"synchronize_with", m_strSynchronizeWith);
384 rgChildren.
Add(
"synchronize_target", m_bSyncTarget.ToString());
386 if (m_nImagesPerBlob > 1)
388 rgChildren.
Add(
"images_per_blob", m_nImagesPerBlob.ToString());
389 rgChildren.
Add(
"output_all_labels", m_bOutputAllLabels.ToString());
390 rgChildren.
Add(
"balance_matches", m_bBalanceMatches.ToString());
394 rgChildren.
Add(
"output_image_information", m_bOutputImageInfo.ToString());
398 rgChildren.
Add(
"enable_noise_for_nonmatch", m_bEnableNoiseForNonMatch.ToString());
399 rgChildren.
Add(m_dataNoiseParam.
ToProto(
"data_noise_param"));
404 rgChildren.
Add(
"enable_debug_output", m_bEnableDebugOutput.ToString());
405 rgChildren.
Add(m_dataDebugParam.
ToProto(
"data_debug_param"));
408 if (m_nForcedPrimaryLabel >= 0)
409 rgChildren.
Add(
"forced_primary_label", m_nForcedPrimaryLabel.ToString());
414 return new RawProto(strName,
"", rgChildren);
430 if ((strVal = rp.
FindValue(
"source")) !=
null)
431 p.source = strVal.Trim(
'\"');
433 if ((strVal = rp.
FindValue(
"batch_size")) !=
null)
434 p.batch_size = uint.Parse(strVal);
436 if ((strVal = rp.
FindValue(
"backend")) !=
null)
441 p.backend =
DB.IMAGEDB;
445 p.backend =
DB.IMAGEDB;
453 throw new Exception(
"Unknown 'backend' value " + strVal);
457 if ((strVal = rp.
FindValue(
"prefetch")) !=
null)
458 p.prefetch = uint.Parse(strVal);
460 if ((strVal = rp.
FindValue(
"enable_random_selection")) !=
null)
461 p.enable_random_selection =
bool.Parse(strVal);
463 if ((strVal = rp.
FindValue(
"enable_pair_selection")) !=
null)
464 p.enable_pair_selection =
bool.Parse(strVal);
466 if ((strVal = rp.
FindValue(
"display_timing")) !=
null)
467 p.display_timing =
bool.Parse(strVal);
469 if ((strVal = rp.
FindValue(
"label_type")) !=
null)
482 throw new Exception(
"Unknown 'label_type' value " + strVal);
486 if ((strVal = rp.
FindValue(
"primary_data")) !=
null)
487 p.primary_data =
bool.Parse(strVal);
489 p.synchronize_with = rp.
FindValue(
"synchronize_with");
491 if ((strVal = rp.
FindValue(
"synchronize_target")) !=
null)
492 p.synchronize_target =
bool.Parse(strVal);
494 if ((strVal = rp.
FindValue(
"images_per_blob")) !=
null)
495 p.images_per_blob =
int.Parse(strVal);
497 if ((strVal = rp.
FindValue(
"output_all_labels")) !=
null)
498 p.output_all_labels =
bool.Parse(strVal);
500 if ((strVal = rp.
FindValue(
"balance_matches")) !=
null)
501 p.balance_matches =
bool.Parse(strVal);
503 if ((strVal = rp.
FindValue(
"output_image_information")) !=
null)
504 p.output_image_information =
bool.Parse(strVal);
506 if ((strVal = rp.
FindValue(
"enable_noise_for_nonmatch")) !=
null)
507 p.enable_noise_for_nonmatch =
bool.Parse(strVal);
510 if (rpDataNoise !=
null)
513 if ((strVal = rp.
FindValue(
"enable_debug_output")) !=
null)
514 p.enable_debug_output =
bool.Parse(strVal);
517 if (rpDataDebug !=
null)
520 if ((strVal = rp.
FindValue(
"forced_primary_label")) !=
null)
521 p.forced_primary_label =
int.Parse(strVal);
523 if ((strVal = rp.
FindValue(
"one_hot_label_size")) !=
null)
524 p.one_hot_label_size =
int.Parse(strVal);
536 Exception m_err =
null;
544 m_uiBatchSize = uiBatchSize;
553 get {
return m_err; }
554 set { m_err = value; }
562 get {
return m_uiBatchSize; }
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.
RawProto FindChild(string strName)
Searches for a given node.
static RawProto Parse(string str)
Parses a prototxt and places it in a new RawProto.
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
The DataDebugParameter is used by the DataParameter when the 'enable_debugging' = True.
RawProto ToProto(string strName)
Convert the DataDebugParameter into a RawProto.
void Copy(DataDebugParameter src)
Copies the specified source data noise parameter to this one.
static DataDebugParameter FromProto(RawProto rp, DataDebugParameter p=null)
Parses the parameter from a RawProto.
The DataNoiseParameter is used by the DataParameter when the 'enable_noise_for_nonmatch' = True,...
RawProto ToProto(string strName)
Convert the DataNoiseParameter into a RawProto.
static DataNoiseParameter FromProto(RawProto rp, DataNoiseParameter p=null)
Parses the parameter from a RawProto.
void Copy(DataNoiseParameter pSrc)
Copies the specified source data noise parameter to this one.
Specifies the parameter for the data layer.
virtual uint batch_size
Specifies the batch size.
DB
Defines the database type to use.
LABEL_TYPE label_type
(optional, default = SINGLE) Specifies the label type: SINGLE - the default which uses the 'Label' fi...
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
bool synchronize_target
(optional, default = false) Specifies whether or not this is a to be synchronized with another data l...
bool display_timing
(optional, default = false) Specifies whether or not to display the timing of each image read.
bool? enable_random_selection
(optional, default = null) Specifies whether or not to randomly query images from the data source....
int images_per_blob
(optional, default = 1) Specifies the number of images to load into each blob channel....
string synchronize_with
(optional, default = null) Specifies a secondary (target) dataset to syncrhonize with.
bool primary_data
(optional, default = true) Specifies whether or not the data is the primary datset as opposed to a se...
DataNoiseParameter data_noise_param
Specifies the DataNoiseParameter used when 'enable_noise_for_nonmatch' = True.
bool enable_noise_for_nonmatch
(optional, default = false) When true an image consisting of noise initialized with noise filler.
int one_hot_label_size
When greater than 0 (default = 0), labels are one-hot encoded to a vector of the one-hot label size (...
bool? enable_pair_selection
(optional, default = null) Specifies whether or not to select images in a pair sequence....
int forced_primary_label
(optional, default = -1) When >= 0, this label is used as the primary image label when 'images_per_bl...
override void Copy(LayerParameterBase src)
Copy on parameter to another.
DB backend
Specifies the backend database.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
DataDebugParameter data_debug_param
Specifies the DataDebugParameter used when 'enable_debug_output' = True.
string source
When used with the DATA parameter, specifies the data 'source' within the database....
bool output_all_labels
(optional, default = false) When using images_per_blob > 1, 'output_all_labels' specifies to output a...
static DataParameter FromProto(RawProto rp, DataParameter p=null)
Parses the parameter from a RawProto.
bool enable_debug_output
(optional, default = false) When true the data sent out through the top are saved as images into the ...
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
EventHandler< VerifyBatchSizeArgs > OnVerifyBatchSize
This event is, optionally, called to verify the batch size of the DataParameter.
uint prefetch
Prefetch queue (Number of batches to prefetch to host memory, increase if data access bandwidth varie...
bool output_image_information
(optional, default = false) When true image information such as index and label are output....
bool balance_matches
(optional, default = true) When using images_per_blob > 1, 'balance_matches' specifies to query image...
DataParameter()
Constructor for the parameter.
The LayerParameterBase is the base class for all other layer specific parameters.
LABEL_TYPE
Defines the label type.
The VerifyBatchSizeArgs class defines the arguments of the OnVerifyBatchSize event.
uint ProposedBatchSize
Specifies the proposed batch size that the DataLayer would like to use.
VerifyBatchSizeArgs(uint uiBatchSize)
VerifyBatchSizeArgs constructor.
Exception Error
Get/set the error value. For example if the receiver of the event determines that the batch size is i...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
@ NONE
No training category specified.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...