MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MathParameter.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 MyCaffe.common.MATH_FUNCTION m_function = MyCaffe.common.MATH_FUNCTION.NOP;
23
26 {
27 }
28
30 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
31 {
32 RawProto proto = RawProto.Parse(br.ReadString());
33 MathParameter p = FromProto(proto);
34
35 if (!bNewInstance)
36 Copy(p);
37
38 return p;
39 }
40
44 public MyCaffe.common.MATH_FUNCTION function
45 {
46 get { return m_function; }
47 set { m_function = value; }
48 }
49
51 public override void Copy(LayerParameterBase src)
52 {
54 m_function = p.m_function;
55 }
56
58 public override LayerParameterBase Clone()
59 {
61 p.Copy(this);
62 return p;
63 }
64
70 public override RawProto ToProto(string strName)
71 {
72 RawProtoCollection rgChildren = new RawProtoCollection();
73
74 rgChildren.Add("fuction", function.ToString());
75
76 return new RawProto(strName, "", rgChildren);
77 }
78
85 {
86 string strVal;
88
89 if ((strVal = rp.FindValue("function")) != null)
90 {
91 if (strVal == MyCaffe.common.MATH_FUNCTION.COS.ToString())
92 p.function = MyCaffe.common.MATH_FUNCTION.COS;
93 else if (strVal == MyCaffe.common.MATH_FUNCTION.SIN.ToString())
94 p.function = MyCaffe.common.MATH_FUNCTION.SIN;
95 else if (strVal == MyCaffe.common.MATH_FUNCTION.TAN.ToString())
96 p.function = MyCaffe.common.MATH_FUNCTION.TAN;
97 else
98 p.function = MyCaffe.common.MATH_FUNCTION.NOP;
99 }
100
101 return p;
102 }
103 }
104}
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 MathLayer.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
static MathParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
MyCaffe.common.MATH_FUNCTION function
Get/set the function to run.
MathParameter()
Constructor for the parameter.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
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