MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
LogParameter.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 LogParameter()
33 {
34 }
35
39 [Description("Specifies the base to use for the log, where y=log_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 log, where 'y = log_babse(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 log, where 'y = log_babse(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 LogParameter 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 LogParameter p = new LogParameter();
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 LogParameter p = new LogParameter();
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
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the LogLayer.
Definition: LogParameter.cs:26
LogParameter()
Constructor for the parameter.
Definition: LogParameter.cs:32
double shift
Specifies the shift to use for the log, where , for base > 0.
Definition: LogParameter.cs:61
double base_val
Specifies the base to use for the log, where , for base > 0.
Definition: LogParameter.cs:41
static LogParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
Definition: LogParameter.cs:79
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: LogParameter.cs:67
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Definition: LogParameter.cs:88
double scale
Specifies the scale to use for the log, where , for base > 0.
Definition: LogParameter.cs:51
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