MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ImageDataParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 uint m_nRandomSkip = 0;
18 bool m_bShuffle = false;
19 uint m_nNewHeight = 0;
20 uint m_nNewWidth = 0;
21 bool m_bIsColor = true;
22 string m_strRootFolder = "";
23
24
27 {
28 }
29
33 [Description("Specifies the amount for the image data layer to skip a few points to avoid all asynchronous sgd clients to start at the same point. The skip point should be set as rand_skip * rand(0,1). Note that the rand_skip should not be larger than the number of keys in the database.")]
34 public uint rand_skip
35 {
36 get { return m_nRandomSkip; }
37 set { m_nRandomSkip = value; }
38 }
39
43 [Description("Specifies whether or not the ImageLayer should shuffle the list of files at each epoch.")]
44 public bool shuffle
45 {
46 get { return m_bShuffle; }
47 set { m_bShuffle = value; }
48 }
49
53 [Description("When > 0, specifies the new height of the images fed into the network (default = 0).")]
54 public uint new_height
55 {
56 get { return m_nNewHeight; }
57 set { m_nNewHeight = value; }
58 }
59
63 [Description("When > 0, specifies the new width of the images fed into the network (default = 0).")]
64 public uint new_width
65 {
66 get { return m_nNewWidth; }
67 set { m_nNewWidth = value; }
68 }
69
73 [Description("Specifies whether or not the image is color or gray-scale.")]
74 public bool is_color
75 {
76 get { return m_bIsColor; }
77 set { m_bIsColor = value; }
78 }
79
83 [Description("Specifies the folder containing the image files.")]
84 public string root_folder
85 {
86 get { return m_strRootFolder; }
87 set { m_strRootFolder = value; }
88 }
89
91 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
92 {
93 RawProto proto = RawProto.Parse(br.ReadString());
95
96 if (!bNewInstance)
97 Copy(p);
98
99 return p;
100 }
101
103 public override void Copy(LayerParameterBase src)
104 {
106 m_nRandomSkip = p.m_nRandomSkip;
107 m_bShuffle = p.m_bShuffle;
108 m_nNewHeight = p.m_nNewHeight;
109 m_nNewWidth = p.m_nNewWidth;
110 m_bIsColor = p.m_bIsColor;
111 m_strRootFolder = p.m_strRootFolder;
112 }
113
115 public override LayerParameterBase Clone()
116 {
118 p.Copy(this);
119 return p;
120 }
121
127 public override RawProto ToProto(string strName)
128 {
129 RawProtoCollection rgChildren = new RawProtoCollection();
130
131 if (rand_skip > 0)
132 rgChildren.Add("rand_skip", rand_skip.ToString());
133
134 rgChildren.Add("shuffle", shuffle.ToString());
135
136 if (new_height > 0)
137 rgChildren.Add("new_height", new_height.ToString());
138
139 if (new_width > 0)
140 rgChildren.Add("new_width", new_width.ToString());
141
142 rgChildren.Add("is_color", is_color.ToString());
143 rgChildren.Add("root_folder", "\"" + root_folder + "\"");
144
145 return new RawProto(strName, "", rgChildren);
146 }
147
155 {
156 string strVal;
157
158 if (p == null)
159 p = new ImageDataParameter();
160
161 if ((strVal = rp.FindValue("rand_skip")) != null)
162 p.rand_skip = uint.Parse(strVal);
163
164 if ((strVal = rp.FindValue("shuffle")) != null)
165 p.shuffle = bool.Parse(strVal);
166
167 if ((strVal = rp.FindValue("new_height")) != null)
168 p.new_height = uint.Parse(strVal);
169
170 if ((strVal = rp.FindValue("new_width")) != null)
171 p.new_width = uint.Parse(strVal);
172
173 if ((strVal = rp.FindValue("is_color")) != null)
174 p.is_color = bool.Parse(strVal);
175
176 if ((strVal = rp.FindValue("root_folder")) != null)
177 p.root_folder = strVal.Trim('\"');
178
179 return p;
180 }
181 }
182}
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
Specifies the parameters for the ImageDataLayer
static ImageDataParameter FromProto(RawProto rp, ImageDataParameter p=null)
Parses the parameter from a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
ImageDataParameter()
Constructor for the parameter.
string root_folder
Specifies the folder containing the image files.
bool shuffle
Specifies whether or not the ImageLayer should shuffle the list of files at each epoch.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
uint new_width
When > 0, specifies the new width of the images fed into the network (default = 0).
uint new_height
When > 0, specifies the new height of the images fed into the network (default = 0).
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
uint rand_skip
Specifies the amount for the image data layer to skip a few points to avoid all asynchronous sgd clie...
bool is_color
Specififies whether or not the image is color or gray-scale.
The LayerParameterBase is the base class for all other layer specific parameters.
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