MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
Normalization2Parameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.ssd
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 bool m_bAcrossSpatial = true;
22 FillerParameter m_scaleFiller = new FillerParameter("constant", 1.0);
23 bool m_bChannelShared = true;
24 float m_fEps = 1e-10f;
25
30 {
31 }
32
36 [Description("Specifies to normalize across the spatial dimensions.")]
37 public bool across_spatial
38 {
39 get { return m_bAcrossSpatial; }
40 set { m_bAcrossSpatial = value; }
41 }
42
46 [Description("Specifies the filler for the initial value of scale, default is 1.0 for all.")]
48 {
49 get { return m_scaleFiller; }
50 set { m_scaleFiller = value; }
51 }
52
56 [Description("Specifies whether or not the scale parameters are shared across channels.")]
57 public bool channel_shared
58 {
59 get { return m_bChannelShared; }
60 set { m_bChannelShared = value; }
61 }
62
66 [Description("Specifies the epsilon for not dividing by zero while normalizing variance.")]
67 public float eps
68 {
69 get { return m_fEps; }
70 set { m_fEps = value; }
71 }
72
79 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
80 {
81 RawProto proto = RawProto.Parse(br.ReadString());
83
84 if (!bNewInstance)
85 Copy(p);
86
87 return p;
88 }
89
94 public override void Copy(LayerParameterBase src)
95 {
97 m_bAcrossSpatial = p.m_bAcrossSpatial;
98 m_bChannelShared = p.m_bChannelShared;
99 m_fEps = p.m_fEps;
100 m_scaleFiller = p.m_scaleFiller.Clone();
101 }
102
107 public override LayerParameterBase Clone()
108 {
110 p.Copy(this);
111 return p;
112 }
113
119 public override RawProto ToProto(string strName)
120 {
121 RawProtoCollection rgChildren = new RawProtoCollection();
122
123 rgChildren.Add("across_spatial", m_bAcrossSpatial.ToString());
124 rgChildren.Add("channel_shared", m_bChannelShared.ToString());
125 rgChildren.Add("esp", m_fEps.ToString());
126 rgChildren.Add(scale_filler.ToProto("scale_filler"));
127
128 return new RawProto(strName, "", rgChildren);
129 }
130
137 {
138 string strVal;
140
141 if ((strVal = rp.FindValue("across_spatial")) != null)
142 p.across_spatial = bool.Parse(strVal);
143
144 if ((strVal = rp.FindValue("channel_shared")) != null)
145 p.channel_shared = bool.Parse(strVal);
146
147 if ((strVal = rp.FindValue("eps")) != null)
148 p.eps = ParseFloat(strVal);
149
150 RawProto rgScaleFiller = rp.FindChild("scale_filler");
151 if (rgScaleFiller != null)
152 p.scale_filler = FillerParameter.FromProto(rgScaleFiller);
153
154 return p;
155 }
156 }
157}
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
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 filler parameters used to create each Filler.
static FillerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
FillerParameter Clone()
Creates a new copy of this instance of the parameter.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the Normalization2Layer used in SSD.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
float eps
Specifies the epsilon for not dividing by zero while normalizing variance.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
static Normalization2Parameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
FillerParameter scale_filler
Specifies the filler for the initial value of scale, default is 1.0 for all.
bool channel_shared
Specifies whether or not the scale parameters are shared across channels.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
bool across_spatial
Specifies to normalize across the spatial dimensions.
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