MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ExpParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
23 [Serializable]
24 [TypeConverter(typeof(ExpandableObjectConverter))]
26 {
27 double m_dfBase = -1.0;
28 double m_dfScale = 1.0;
29 double m_dfShift = 0.0;
30
32 public ExpParameter()
33 {
34 }
35
39 [Description("Specifies the base to use for the exponent, where 'y = base ^ (shift + scale * x), for base > 0'.")]
40 public double base_val
41 {
42 get { return m_dfBase; }
43 set { m_dfBase = value; }
44 }
45
49 [Description("Specifies the scale to use for the exponent, where 'y = base ^ (shift + scale * x), for base > 0'.")]
50 public double scale
51 {
52 get { return m_dfScale; }
53 set { m_dfScale = value; }
54 }
55
59 [Description("Specifies the shift to use for the exponent, where 'y = base ^ (shift + scale * x), for base > 0'.")]
60 public double shift
61 {
62 get { return m_dfShift; }
63 set { m_dfShift = value; }
64 }
65
67 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
68 {
69 RawProto proto = RawProto.Parse(br.ReadString());
70 ExpParameter p = FromProto(proto);
71
72 if (!bNewInstance)
73 Copy(p);
74
75 return p;
76 }
77
79 public override void Copy(LayerParameterBase src)
80 {
82 m_dfBase = p.m_dfBase;
83 m_dfScale = p.m_dfScale;
84 m_dfShift = p.m_dfShift;
85 }
86
88 public override LayerParameterBase Clone()
89 {
90 ExpParameter p = new ExpParameter();
91 p.Copy(this);
92 return p;
93 }
94
100 public override RawProto ToProto(string strName)
101 {
102 RawProtoCollection rgChildren = new RawProtoCollection();
103
104 rgChildren.Add("base", base_val.ToString());
105
106 if (scale != 1.0)
107 rgChildren.Add("scale", scale.ToString());
108
109 if (shift != 0)
110 rgChildren.Add("shift", shift.ToString());
111
112 return new RawProto(strName, "", rgChildren);
113 }
114
121 {
122 string strVal;
123 ExpParameter p = new ExpParameter();
124
125 if ((strVal = rp.FindValue("base")) != null)
126 p.base_val = ParseDouble(strVal);
127
128 if ((strVal = rp.FindValue("scale")) != null)
129 p.scale = ParseDouble(strVal);
130
131 if ((strVal = rp.FindValue("shift")) != null)
132 p.shift = ParseDouble(strVal);
133
134 return p;
135 }
136 }
137}
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 ExpLayer.
Definition: ExpParameter.cs:26
double base_val
Specifies the base to use for the exponent, where , for base > 0.
Definition: ExpParameter.cs:41
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Definition: ExpParameter.cs:88
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: ExpParameter.cs:67
double shift
Specifies the shift to use for the exponent, where , for base > 0.
Definition: ExpParameter.cs:61
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
static ExpParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
ExpParameter()
Constructor for the parameter.
Definition: ExpParameter.cs:32
override void Copy(LayerParameterBase src)
Copy on parameter to another.
Definition: ExpParameter.cs:79
double scale
Specifies the scale to use for the exponent, where , for base > 0.
Definition: ExpParameter.cs:51
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