MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ScaleParameter.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 bool m_bBiasTerm = false;
18 FillerParameter m_FillerBias = null;
19
22 {
23 }
24
29 [Description("Specifies whether to also learn a 'bias' (eqivalent to a ScalarLayer + BiasLayer, but may be more efficient).")]
30 public bool bias_term
31 {
32 get { return m_bBiasTerm; }
33 set { m_bBiasTerm = value; }
34 }
35
39 [Description("Specifies the filler used for bias filling.")]
41 {
42 get { return m_FillerBias; }
43 set { m_FillerBias = value; }
44 }
45
47 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
48 {
49 RawProto proto = RawProto.Parse(br.ReadString());
50 ScaleParameter p = FromProto(proto);
51
52 if (!bNewInstance)
53 Copy(p);
54
55 return p;
56 }
57
59 public override void Copy(LayerParameterBase src)
60 {
62
63 base.Copy(src);
64
65 m_bBiasTerm = p.m_bBiasTerm;
66
67 if (p.m_FillerBias != null)
68 m_FillerBias = p.m_FillerBias.Clone();
69 }
70
72 public override LayerParameterBase Clone()
73 {
75 p.Copy(this);
76 return p;
77 }
78
84 public override RawProto ToProto(string strName)
85 {
86 RawProtoCollection rgChildren = new RawProtoCollection();
87
88 if (bias_term != false)
89 {
90 rgChildren.Add("bias_term", bias_term.ToString());
91
92 if (bias_filler != null)
93 rgChildren.Add(bias_filler.ToProto("bias_filler"));
94 }
95
96 return new RawProto(strName, "", rgChildren);
97 }
98
104 public static new ScaleParameter FromProto(RawProto rp)
105 {
106 string strVal;
108
109 if ((strVal = rp.FindValue("bias_term")) != null)
110 p.bias_term = bool.Parse(strVal);
111
112 RawProto rpBiasFiller = rp.FindChild("bias_filler");
113 if (rpBiasFiller != null)
114 p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
115
116 return p;
117 }
118 }
119}
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
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.
abstract void Copy(LayerParameterBase src)
Copy on parameter to another.
Specifies the parameters for the ScaleLayer.
ScaleParameter()
Constructor for the parameter.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
static new ScaleParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
bool bias_term
Whether to also learn a bias (equivalent to a ScalarLayer + BiasLayer, but may be more efficient).
FillerParameter bias_filler
Filler used for bias filling.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
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.
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