MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
BiasParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 int m_nAxis = 1;
18 int m_nNumAxes = 1;
19 FillerParameter m_filler = null;
20
23 {
24 }
25
44 [Description("Specifies the first axis of the first input Blob (bottom[0]) along which to apply the second input Blob (bottom[1]). May be negative to index from the end (e.g., -1 for the last axis).")]
45 public int axis
46 {
47 get { return m_nAxis; }
48 set { m_nAxis = value; }
49 }
50
60 [Description("'num_axes' is ignored unless just one bottom is given and the bias is a learned parameter of the layer. Otherwise, num_axis is determined by the number of axes of the input (bottom[0] covered by the bias parameter, or -1 to cover all axes of bottom[0] starting from 'axis'. Note: Set 'num_axis' := 0 to add a zero-axis Blob: a scalar.")]
61 public int num_axes
62 {
63 get { return m_nNumAxes; }
64 set { m_nNumAxes = value; }
65 }
66
76 [Description("Specifies the filler for the initialization of the learned bias parameter. 'filler' is ignored when more than one bottom is given and the bias is NOT a leanred parameter of the layer. The default is the zero (0) initialization, resulting in the BiasLayer initially performing the identity operation.")]
78 {
79 get { return m_filler; }
80 set { m_filler = value; }
81 }
82
84 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
85 {
86 RawProto proto = RawProto.Parse(br.ReadString());
87 BiasParameter p = FromProto(proto);
88
89 if (!bNewInstance)
90 Copy(p);
91
92 return p;
93 }
94
96 public override void Copy(LayerParameterBase src)
97 {
99 m_nAxis = p.m_nAxis;
100 m_nNumAxes = p.m_nNumAxes;
101
102 if (p.m_filler != null)
103 m_filler = p.m_filler.Clone();
104 else
105 m_filler = null;
106 }
107
109 public override LayerParameterBase Clone()
110 {
112 p.Copy(this);
113 return p;
114 }
115
121 public override RawProto ToProto(string strName)
122 {
123 RawProtoCollection rgChildren = new RawProtoCollection();
124
125 if (axis != 1)
126 rgChildren.Add("axis", axis.ToString());
127
128 if (num_axes != 1)
129 rgChildren.Add("num_axes", num_axes.ToString());
130
131 if (m_filler != null)
132 rgChildren.Add(m_filler.ToProto("filler"));
133
134 return new RawProto(strName, "", rgChildren);
135 }
136
143 {
144 string strVal;
146
147 if ((strVal = rp.FindValue("axis")) != null)
148 p.axis = int.Parse(strVal);
149
150 if ((strVal = rp.FindValue("num_axes")) != null)
151 p.num_axes = int.Parse(strVal);
152
153 if ((rp = rp.FindChild("filler")) != null)
154 p.m_filler = FillerParameter.FromProto(rp);
155
156 return p;
157 }
158 }
159}
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 parameters for the BiasLayer
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
BiasParameter()
Constructor for the parameter.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static BiasParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int axis
The first axis of bottom[0] (the first input Blob) along which to apply bottom[1] (the second input B...
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
int num_axes
(num_axes is ignored unless just one bottom is given and the bias is a learned parameter of the layer...
FillerParameter filler
(filler is ignored unless just one bottom is given and the bias is a learned parameter of the layer....
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.
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