MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ExpansionParameter.cs
1using System;
2using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8using MyCaffe.basecode;
9
10namespace MyCaffe.param.ssd
11{
19 [Serializable]
20 [TypeConverter(typeof(ExpandableObjectConverter))]
22 {
23 float m_fProb = 0;
24 float m_fMaxExpandRatio = 1.0f;
25
30 public ExpansionParameter(bool bActive) : base(bActive)
31 {
32 }
33
37 [Description("Get/set probability of using this expansion policy.")]
38 public float prob
39 {
40 get { return m_fProb; }
41 set { m_fProb = value; }
42 }
43
47 [Description("Get/set the ratio to expand the image.")]
48 public float max_expand_ratio
49 {
50 get { return m_fMaxExpandRatio; }
51 set { m_fMaxExpandRatio = value; }
52 }
53
58 public override void Copy(OptionalParameter src)
59 {
60 base.Copy(src);
61
62 if (src is ExpansionParameter)
63 {
65 m_fProb = p.prob;
66 m_fMaxExpandRatio = p.max_expand_ratio;
67 }
68 }
69
75 {
77 p.Copy(this);
78 return p;
79 }
80
86 public override RawProto ToProto(string strName)
87 {
88 RawProto rpBase = base.ToProto("option");
89 RawProtoCollection rgChildren = new RawProtoCollection();
90
91 rgChildren.Add(rpBase);
92 rgChildren.Add(new RawProto("active", Active.ToString()));
93 rgChildren.Add(new RawProto("prob", prob.ToString()));
94 rgChildren.Add(new RawProto("max_expand_ratio", max_expand_ratio.ToString()));
95
96 return new RawProto(strName, "", rgChildren);
97 }
98
105 {
107 string strVal;
108
109 RawProto rpOption = rp.FindChild("option");
110 if (rpOption != null)
111 ((OptionalParameter)p).Copy(OptionalParameter.FromProto(rpOption));
112
113 if ((strVal = rp.FindValue("prob")) != null)
114 p.prob = BaseParameter.ParseFloat(strVal);
115
116 if ((strVal = rp.FindValue("max_expand_ratio")) != null)
118
119 return p;
120 }
121 }
122}
The BaseParameter class is the base class for all other parameter classes.
static float ParseFloat(string strVal)
Parse float values using the US culture if the decimal separator = '.', then using the native culture...
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
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
string FindValue(string strName)
Searches for a falue of a node within this nodes children.
Definition: RawProto.cs:105
The OptionalParameter is the base class for parameters that are optional such as the MaskParameter,...
static OptionalParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
OptionalParameter(bool bActive=false)
The constructor.
bool Active
When active, the parameter is used, otherwise it is ignored.
Specifies the parameters for the ExpansionParameter used with SSD.
float max_expand_ratio
Get/set the ratio to expand the image.
float prob
Get/set probability of using this expansion policy.
static new ExpansionParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert this object to a raw proto.
ExpansionParameter Clone()
Return a clone of the object.
override void Copy(OptionalParameter src)
Copy the object.
ExpansionParameter(bool bActive)
The constructor.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.ssd namespace contains all SSD related parameter objects that correspond to the nat...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12