MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
InterpParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
15 [Serializable]
16 [TypeConverter(typeof(ExpandableObjectConverter))]
18 {
19 int? m_nHeight = null;
20 int? m_nWidth = null;
21 int? m_nZoomFactor = null;
22 int? m_nShrinkFactor = null;
23 int m_nPadBeg = 0;
24 int m_nPadEnd = 0;
25
28 {
29 }
30
34 [Description("Specifies the height of the output.")]
35 public int? height
36 {
37 get { return m_nHeight; }
38 set { m_nHeight = value; }
39 }
40
44 [Description("Specifies the width of the output.")]
45 public int? width
46 {
47 get { return m_nWidth; }
48 set { m_nWidth = value; }
49 }
50
54 [Description("Specifies the zoom factor of the output.")]
55 public int? zoom_factor
56 {
57 get { return m_nZoomFactor; }
58 set { m_nZoomFactor = value; }
59 }
60
64 [Description("Specifies the shrink factor of the output.")]
65 public int? shrink_factor
66 {
67 get { return m_nShrinkFactor; }
68 set { m_nShrinkFactor = value; }
69 }
70
74 [Description("Specifies the padding at the begin of the output.")]
75 public int pad_beg
76 {
77 get { return m_nPadBeg; }
78 set { m_nPadBeg = value; }
79 }
80
84 [Description("Specifies the padding at the end of the output.")]
85 public int pad_end
86 {
87 get { return m_nPadEnd; }
88 set { m_nPadEnd = value; }
89 }
90
92 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
93 {
94 RawProto proto = RawProto.Parse(br.ReadString());
95 InterpParameter p = FromProto(proto);
96
97 if (!bNewInstance)
98 Copy(p);
99
100 return p;
101 }
102
104 public override void Copy(LayerParameterBase src)
105 {
107
108 m_nHeight = p.height;
109 m_nWidth = p.width;
110 m_nZoomFactor = p.zoom_factor;
111 m_nShrinkFactor = p.shrink_factor;
112 m_nPadBeg = p.pad_beg;
113 m_nPadEnd = p.pad_end;
114 }
115
117 public override LayerParameterBase Clone()
118 {
120 p.Copy(this);
121 return p;
122 }
123
129 public override RawProto ToProto(string strName)
130 {
131 RawProtoCollection rgChildren = new RawProtoCollection();
132
133 if (height.HasValue)
134 rgChildren.Add("height", height.ToString());
135 if (width.HasValue)
136 rgChildren.Add("width", width.ToString());
137 if (zoom_factor.HasValue)
138 rgChildren.Add("zoom_factor", zoom_factor.ToString());
139 if (shrink_factor.HasValue)
140 rgChildren.Add("shrink_factor", shrink_factor.ToString());
141 rgChildren.Add("pad_beg", pad_beg.ToString());
142 rgChildren.Add("pad_end", pad_end.ToString());
143
144 return new RawProto(strName, "", rgChildren);
145 }
146
153 {
154 string strVal;
156
157 if ((strVal = rp.FindValue("height")) != null)
158 p.height = int.Parse(strVal);
159
160 if ((strVal = rp.FindValue("width")) != null)
161 p.width = int.Parse(strVal);
162
163 if ((strVal = rp.FindValue("zoom_factor")) != null)
164 p.zoom_factor = int.Parse(strVal);
165
166 if ((strVal = rp.FindValue("shrink_factor")) != null)
167 p.shrink_factor = int.Parse(strVal);
168
169 if ((strVal = rp.FindValue("pad_beg")) != null)
170 p.pad_beg = int.Parse(strVal);
171
172 if ((strVal = rp.FindValue("pad_end")) != null)
173 p.pad_end = int.Parse(strVal);
174
175 return p;
176 }
177 }
178}
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 InterpLayer.
InterpParameter()
Constructor for the parameter.
static InterpParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
int? zoom_factor
Specifies the height of the output.
int? height
Specifies the height of the output.
int? width
Specifies the width of the output.
int pad_beg
Specifies the padding at the begin of the output.
int? shrink_factor
Specifies the shrink factor of the output.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
int pad_end
Specifies the padding at the end of the output.
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