MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MemoryDataParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 uint m_nBatchSize;
18 uint m_nDataChannels;
19 uint m_nDataHeight;
20 uint m_nDataWidth;
21 uint m_nLabelChannels = 1;
22 uint m_nLabelHeight = 1;
23 uint m_nLabelWidth = 1;
24 uint m_nClipLength1 = 0;
25 uint m_nClipLength2 = 0;
26 LABEL_TYPE m_labelType = LABEL_TYPE.SINGLE;
27 bool m_bPrimaryData = true;
28
31 {
32 }
33
37 [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'.")]
38 public bool primary_data
39 {
40 get { return m_bPrimaryData; }
41 set { m_bPrimaryData = value; }
42 }
43
47 [Category("Labels"), Description("Specifies the label type: SINGLE - the default which uses the 'Label' field, or MULTIPLE - which uses the 'DataCriteria' field.")]
49 {
50 get { return m_labelType; }
51 set { m_labelType = value; }
52 }
53
57 [Description("Batch size.")]
58 public uint batch_size
59 {
60 get { return m_nBatchSize; }
61 set { m_nBatchSize = value; }
62 }
63
67 [Description("The number of channels in the data.")]
68 public uint channels
69 {
70 get { return m_nDataChannels; }
71 set { m_nDataChannels = value; }
72 }
73
77 [Description("Specifies the height of the data.")]
78 public uint height
79 {
80 get { return m_nDataHeight; }
81 set { m_nDataHeight = value; }
82 }
83
87 [Description("Specifies the width of the data.")]
88 public uint width
89 {
90 get { return m_nDataWidth; }
91 set { m_nDataWidth = value; }
92 }
93
97 [Description("The number of channels in the label (default = 1).")]
98 public uint label_channels
99 {
100 get { return m_nLabelChannels; }
101 set { m_nLabelChannels = value; }
102 }
103
107 [Description("Specifies the height of the label (default = 1).")]
108 public uint label_height
109 {
110 get { return m_nLabelHeight; }
111 set { m_nLabelHeight = value; }
112 }
113
117 [Description("Specifies the width of the label (default = 1).")]
118 public uint label_width
119 {
120 get { return m_nLabelWidth; }
121 set { m_nLabelWidth = value; }
122 }
123
131 [Description("Specifies the first clip length used with LSTM layers (default = 0, which means unused)")]
132 public uint clip_length1
133 {
134 get { return m_nClipLength1; }
135 set { m_nClipLength1 = value; }
136 }
137
145 [Description("Specifies the second clip length used with LSTM layers (default = 0, which means unused)")]
146 public uint clip_length2
147 {
148 get { return m_nClipLength2; }
149 set { m_nClipLength2 = value; }
150 }
151
153 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
154 {
155 RawProto proto = RawProto.Parse(br.ReadString());
157
158 if (!bNewInstance)
159 Copy(p);
160
161 return p;
162 }
163
165 public override void Copy(LayerParameterBase src)
166 {
168 m_nBatchSize = p.m_nBatchSize;
169 m_nDataChannels = p.m_nDataChannels;
170 m_nDataHeight = p.m_nDataHeight;
171 m_nDataWidth = p.m_nDataWidth;
172 m_nLabelChannels = p.m_nLabelChannels;
173 m_nLabelHeight = p.m_nLabelHeight;
174 m_nLabelWidth = p.m_nLabelWidth;
175 m_labelType = p.m_labelType;
176 m_bPrimaryData = p.m_bPrimaryData;
177 m_nClipLength1 = p.m_nClipLength1;
178 m_nClipLength2 = p.m_nClipLength2;
179 }
180
182 public override LayerParameterBase Clone()
183 {
185 p.Copy(this);
186 return p;
187 }
188
194 public override RawProto ToProto(string strName)
195 {
196 RawProtoCollection rgChildren = new RawProtoCollection();
197
198 rgChildren.Add("batch_size", batch_size.ToString());
199 rgChildren.Add("channels", channels.ToString());
200 rgChildren.Add("height", height.ToString());
201 rgChildren.Add("width", width.ToString());
202 rgChildren.Add("label_channels", label_channels.ToString());
203 rgChildren.Add("label_height", label_height.ToString());
204 rgChildren.Add("label_width", label_width.ToString());
205
206 if (label_type != LABEL_TYPE.SINGLE)
207 rgChildren.Add("label_type", label_type.ToString());
208
209 if (primary_data == false)
210 rgChildren.Add("primary_data", primary_data.ToString());
211
212 if (m_nClipLength1> 0)
213 rgChildren.Add("clip_length1", m_nClipLength1.ToString());
214
215 if (m_nClipLength2 > 0)
216 rgChildren.Add("clip_length2", m_nClipLength2.ToString());
217
218 return new RawProto(strName, "", rgChildren);
219 }
220
227 {
228 string strVal;
230
231 if ((strVal = rp.FindValue("batch_size")) != null)
232 p.m_nBatchSize = uint.Parse(strVal);
233
234 if ((strVal = rp.FindValue("channels")) != null)
235 p.channels = uint.Parse(strVal);
236
237 if ((strVal = rp.FindValue("height")) != null)
238 p.height = uint.Parse(strVal);
239
240 if ((strVal = rp.FindValue("width")) != null)
241 p.width = uint.Parse(strVal);
242
243 if ((strVal = rp.FindValue("label_channels")) != null)
244 p.label_channels = uint.Parse(strVal);
245
246 if ((strVal = rp.FindValue("label_height")) != null)
247 p.label_height = uint.Parse(strVal);
248
249 if ((strVal = rp.FindValue("label_width")) != null)
250 p.label_width = uint.Parse(strVal);
251
252 if ((strVal = rp.FindValue("label_type")) != null)
253 {
254 switch (strVal)
255 {
256 case "NONE":
257 p.label_type = LABEL_TYPE.NONE;
258 break;
259
260 case "SINGLE":
261 p.label_type = LABEL_TYPE.SINGLE;
262 break;
263
264 case "MULTIPLE":
265 p.label_type = LABEL_TYPE.MULTIPLE;
266 break;
267
268 default:
269 throw new Exception("Unknown 'label_type' value " + strVal);
270 }
271 }
272
273 if ((strVal = rp.FindValue("primary_data")) != null)
274 p.primary_data = bool.Parse(strVal);
275
276 if ((strVal = rp.FindValue("clip_length1")) != null)
277 {
278 int nVal = int.Parse(strVal);
279 if (nVal < 0)
280 nVal = 0;
281
282 p.clip_length1 = (uint)nVal;
283 }
284
285 if ((strVal = rp.FindValue("clip_length2")) != null)
286 {
287 int nVal = int.Parse(strVal);
288 if (nVal < 0)
289 nVal = 0;
290
291 p.clip_length2 = (uint)nVal;
292 }
293
294 return p;
295 }
296 }
297}
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.
LABEL_TYPE
Defines the label type.
Specifies the parameters used by the MemoryDataLayer.
uint clip_length1
Specifies the clip length 1 (default = 0, which means unused).
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
uint clip_length2
Specifies the clip length 2 (default = 0, which means unused).
bool primary_data
(optional, default = true) Specifies whether or not the data is the primary datset as opposed to a se...
uint width
The width of the data.
LABEL_TYPE label_type
(optional, default = SINGLE) Specifies the label type: SINGLE - the default which uses the 'Label' fi...
MemoryDataParameter()
Constructor for the parameter.
uint label_height
The height of the label.
uint label_width
The width of the label.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static MemoryDataParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
uint channels
The number of channels in the data.
uint label_channels
The number of channels in the label.
uint height
The height of the data.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
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-...
Definition: Annotation.cs:12