MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MVNParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
18 [Serializable]
19 [TypeConverter(typeof(ExpandableObjectConverter))]
21 {
22 bool m_bNormalizeVariance = true;
23 bool m_bAcrossChannels = false;
24 double m_dfEps = 1e-9;
25
27 public MVNParameter()
28 {
29 }
30
34 [Description("Specifies whether or not to normalize the variance.")]
36 {
37 get { return m_bNormalizeVariance; }
38 set { m_bNormalizeVariance = value; }
39 }
40
44 [Description("Specifies whether or not to normalize accross channels.")]
45 public bool across_channels
46 {
47 get { return m_bAcrossChannels; }
48 set { m_bAcrossChannels = value; }
49 }
50
54 [Description("Specifies a small value to avoid divide by zero.")]
55 [Browsable(false)]
56 public double eps
57 {
58 get { return m_dfEps; }
59 set { m_dfEps = value; }
60 }
61
63 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
64 {
65 RawProto proto = RawProto.Parse(br.ReadString());
66 MVNParameter 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 m_bNormalizeVariance = p.m_bNormalizeVariance;
79 m_bAcrossChannels = p.m_bAcrossChannels;
80 m_dfEps = p.m_dfEps;
81 }
82
84 public override LayerParameterBase Clone()
85 {
86 MVNParameter p = new MVNParameter();
87 p.Copy(this);
88 return p;
89 }
90
96 public override RawProto ToProto(string strName)
97 {
98 RawProtoCollection rgChildren = new RawProtoCollection();
99
100 if (normalize_variance != true)
101 rgChildren.Add("normalize_variance", normalize_variance.ToString());
102
103 if (across_channels != false)
104 rgChildren.Add("across_channels", across_channels.ToString());
105
106 if (eps != 1e-9)
107 rgChildren.Add("eps", eps.ToString());
108
109 return new RawProto(strName, "", rgChildren);
110 }
111
118 {
119 string strVal;
120 MVNParameter p = new MVNParameter();
121
122 if ((strVal = rp.FindValue("normalize_variance")) != null)
123 p.normalize_variance = bool.Parse(strVal);
124
125 if ((strVal = rp.FindValue("across_channels")) != null)
126 p.across_channels = bool.Parse(strVal);
127
128 if ((strVal = rp.FindValue("eps")) != null)
129 p.eps = ParseDouble(strVal);
130
131 return p;
132 }
133 }
134}
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 MVNLayer.
Definition: MVNParameter.cs:21
double eps
Specifies a small value to avoid divide by zero.
Definition: MVNParameter.cs:57
static MVNParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
Definition: MVNParameter.cs:96
MVNParameter()
Constructor for the parameter.
Definition: MVNParameter.cs:27
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: MVNParameter.cs:63
bool across_channels
Specifies whether or not to normalize accross channels.
Definition: MVNParameter.cs:46
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Definition: MVNParameter.cs:84
override void Copy(LayerParameterBase src)
Copy on parameter to another.
Definition: MVNParameter.cs:75
bool normalize_variance
Specifies whether or not to normalize the variance.
Definition: MVNParameter.cs:36
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