MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
PowerParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
19 [Serializable]
20 [TypeConverter(typeof(ExpandableObjectConverter))]
22 {
23 double m_dfPower = 1.0;
24 double m_dfScale = 1.0;
25 double m_dfShift = 0.0;
26
29 {
30 }
31
35 [Description("Specifies power value in the formula 'x = (shift + scale * x)^power'.")]
36 public double power
37 {
38 get { return m_dfPower; }
39 set { m_dfPower = value; }
40 }
41
45 [Description("Specifies scale value in the formula 'x = (shift + scale * x)^power'.")]
46 public double scale
47 {
48 get { return m_dfScale; }
49 set { m_dfScale = value; }
50 }
51
55 [Description("Specifies shift value in the formula 'x = (shift + scale * x)^power'.")]
56 public double shift
57 {
58 get { return m_dfShift; }
59 set { m_dfShift = value; }
60 }
61
63 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
64 {
65 RawProto proto = RawProto.Parse(br.ReadString());
66 PowerParameter p = FromProto(proto);
67
68 if (!bNewInstance)
69 Copy(p);
70
71 return p;
72 }
73
75 public override void Copy(LayerParameterBase src)
76 {
78
79 m_dfPower = p.m_dfPower;
80 m_dfScale = p.m_dfScale;
81 m_dfShift = p.m_dfShift;
82 }
83
85 public override LayerParameterBase Clone()
86 {
88 p.Copy(this);
89 return p;
90 }
91
97 public override RawProto ToProto(string strName)
98 {
99 RawProtoCollection rgChildren = new RawProtoCollection();
100
101 rgChildren.Add("power", power.ToString());
102 rgChildren.Add("scale", scale.ToString());
103 rgChildren.Add("shift", shift.ToString());
104
105 return new RawProto(strName, "", rgChildren);
106 }
107
114 {
115 string strVal;
117
118 if ((strVal = rp.FindValue("power")) != null)
119 p.power = ParseDouble(strVal);
120
121 if ((strVal = rp.FindValue("scale")) != null)
122 p.scale = ParseDouble(strVal);
123
124 if ((strVal = rp.FindValue("shift")) != null)
125 p.shift = ParseDouble(strVal);
126
127 return p;
128 }
129 }
130}
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
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the PowerLayer.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
double power
Specifies power value in the formula .
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static PowerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
double scale
Specifies scale value in the formula .
PowerParameter()
Constructor for the parameter.
double shift
Specifies shift value in the formula .
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
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