MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
GradientScaleParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
28 [Serializable]
29 [TypeConverter(typeof(ExpandableObjectConverter))]
31 {
32 double m_dfLowerBound = 0.0;
33 double m_dfUpperBound = 1.0;
34 double m_dfAlpha = 10.0;
35 double m_dfMaxIter = 1;
36
39 {
40 }
41
45 [Description("Specifies the lower bound of the height used for scaling.")]
46 public double lower_bound
47 {
48 get { return m_dfLowerBound; }
49 set { m_dfLowerBound = value; }
50 }
51
55 [Description("Specifies the upper bound of the height used for scaling.")]
56 public double upper_bound
57 {
58 get { return m_dfUpperBound; }
59 set { m_dfUpperBound = value; }
60 }
61
65 [Description("Specifies the alpha value applied to the current iter/max_iter, used when scaling.")]
66 public double alpha
67 {
68 get { return m_dfAlpha; }
69 set { m_dfAlpha = value; }
70 }
71
75 [Description("Specifies the maximum iteration used when scaling.")]
76 public double max_iter
77 {
78 get { return m_dfMaxIter; }
79 set { m_dfMaxIter = value; }
80 }
81
88 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
89 {
90 RawProto proto = RawProto.Parse(br.ReadString());
92
93 if (!bNewInstance)
94 Copy(p);
95
96 return p;
97 }
98
103 public override void Copy(LayerParameterBase src)
104 {
106 m_dfLowerBound = p.m_dfLowerBound;
107 m_dfUpperBound = p.m_dfUpperBound;
108 m_dfAlpha = p.m_dfAlpha;
109 m_dfMaxIter = p.m_dfMaxIter;
110 }
111
116 public override LayerParameterBase Clone()
117 {
119 p.Copy(this);
120 return p;
121 }
122
128 public override RawProto ToProto(string strName)
129 {
130 RawProtoCollection rgChildren = new RawProtoCollection();
131
132 rgChildren.Add("lower_bound", lower_bound.ToString());
133 rgChildren.Add("upper_bound", upper_bound.ToString());
134 rgChildren.Add("alpha", alpha.ToString());
135 rgChildren.Add("max_iter", max_iter.ToString());
136
137 return new RawProto(strName, "", rgChildren);
138 }
139
146 {
147 string strVal;
149
150 if ((strVal = rp.FindValue("lower_bound")) != null)
151 p.lower_bound = ParseDouble(strVal);
152
153 if ((strVal = rp.FindValue("upper_bound")) != null)
154 p.upper_bound = ParseDouble(strVal);
155
156 if ((strVal = rp.FindValue("alpha")) != null)
157 p.alpha = ParseDouble(strVal);
158
159 if ((strVal = rp.FindValue("max_iter")) != null)
160 p.max_iter = ParseDouble(strVal);
161
162 return p;
163 }
164 }
165}
static double ParseDouble(string strVal)
Parse double values using the US culture if the decimal separator = '.', then using the native cultur...
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 GradientScaleLayer.
double lower_bound
Specifies the lower bound of the height used for scaling.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
double alpha
Specifies the alpha value applied to the current iter/max_iter, used when scaling.
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.
double max_iter
Specifies the maximum iteration used when scaling.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
GradientScaleParameter()
Constructor for the parameter.
static GradientScaleParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
double upper_bound
Specifies the upper bound of the height used for scaling.
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