MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SPPParameter.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 {
23 uint m_nPyramidHeight;
24
26 public SPPParameter()
27 : base()
28 {
29 }
30
34 [Description("Specifies the pooling method to use.")]
36 {
37 get { return m_method; }
38 set { m_method = value; }
39 }
40
44 [Description("Specifies the pyramid height.")]
45 public uint pyramid_height
46 {
47 get { return m_nPyramidHeight; }
48 set { m_nPyramidHeight = value; }
49 }
50
52 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
53 {
54 RawProto proto = RawProto.Parse(br.ReadString());
55 SPPParameter p = FromProto(proto);
56
57 if (!bNewInstance)
58 Copy(p);
59
60 return p;
61 }
62
64 public override void Copy(LayerParameterBase src)
65 {
66 base.Copy(src);
67
68 if (src is SPPParameter)
69 {
71 m_method = p.m_method;
72 m_nPyramidHeight = p.m_nPyramidHeight;
73 }
74 }
75
77 public override LayerParameterBase Clone()
78 {
79 SPPParameter p = new SPPParameter();
80 p.Copy(this);
81 return p;
82 }
83
85 public override RawProto ToProto(string strName)
86 {
87 RawProto rpBase = base.ToProto("engine");
88 RawProtoCollection rgChildren = new RawProtoCollection();
89
90 rgChildren.Add(rpBase.Children);
91 rgChildren.Add("method", pool.ToString());
92 rgChildren.Add("pyramid_height", pyramid_height.ToString());
93
94 return new RawProto(strName, "", rgChildren);
95 }
96
102 public static new SPPParameter FromProto(RawProto rp)
103 {
104 string strVal;
105 SPPParameter p = new SPPParameter();
106
108
109 if ((strVal = rp.FindValue("method")) != null)
110 {
111 switch (strVal)
112 {
113 case "MAX":
115 break;
116
117 case "AVE":
119 break;
120
121 case "STOCHASTIC":
122 p.pool = PoolingParameter.PoolingMethod.STOCHASTIC;
123 break;
124
125 default:
126 throw new Exception("Unknown pooling 'method' value: " + strVal);
127 }
128 }
129
130 if ((strVal = rp.FindValue("pyramid_height")) != null)
131 p.pyramid_height = uint.Parse(strVal);
132
133 return p;
134 }
135 }
136}
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
RawProtoCollection Children
Returns a collection of this nodes child nodes.
Definition: RawProto.cs:96
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 whether to use the NVIDIA cuDnn version or Caffe version of a given forward/backward operat...
static EngineParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the PoolingLayer.
PoolingMethod
Defines the pooling method.
The SPPParameter specifies the parameters for the SPPLayer.
Definition: SPPParameter.cs:21
SPPParameter()
Constructor for the parameter.
Definition: SPPParameter.cs:26
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
Definition: SPPParameter.cs:85
uint pyramid_height
Specifies the pyramid height.
Definition: SPPParameter.cs:46
static new SPPParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Definition: SPPParameter.cs:77
override void Copy(LayerParameterBase src)
Copy on parameter to another.
Definition: SPPParameter.cs:64
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: SPPParameter.cs:52
PoolingParameter.PoolingMethod pool
Specifies the pooling method to use.
Definition: SPPParameter.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