MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SerfParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.beta
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 double m_dfThreshold = 20;
18
21 : base()
22 {
23 }
24
29 public string useCaffeReason()
30 {
31 return "Currenly only CAFFE supported.";
32 }
33
39 public bool useCudnn()
40 {
41 return false;
42 }
43
50 [Description("Specifies the max threshold value used in exp functions.")]
51 public double threshold
52 {
53 get { return m_dfThreshold; }
54 set { m_dfThreshold = value; }
55 }
56
58 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
59 {
60 RawProto proto = RawProto.Parse(br.ReadString());
61 SerfParameter p = FromProto(proto);
62
63 if (!bNewInstance)
64 Copy(p);
65
66 return p;
67 }
68
70 public override void Copy(LayerParameterBase src)
71 {
72 base.Copy(src);
73
74 if (src is SerfParameter)
75 {
77 m_dfThreshold = p.m_dfThreshold;
78 }
79 }
80
82 public override LayerParameterBase Clone()
83 {
85 p.Copy(this);
86 return p;
87 }
88
90 public override RawProto ToProto(string strName)
91 {
92 RawProto rpBase = base.ToProto("engine");
93 RawProtoCollection rgChildren = new RawProtoCollection();
94
95 rgChildren.Add(rpBase.Children);
96
97 if (threshold != 0)
98 rgChildren.Add("threshold", threshold.ToString());
99
100 return new RawProto(strName, "", rgChildren);
101 }
102
108 public static new SerfParameter FromProto(RawProto rp)
109 {
110 string strVal;
112
114
115 if ((strVal = rp.FindValue("threshold")) != null)
116 p.threshold = ParseDouble(strVal);
117
118 return p;
119 }
120 }
121}
static double ParseDouble(string strVal)
Parse double values using the US culture if the decimal separator = '.', then using the native cultur...
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...
EngineParameter()
Constructor for the parameter.
static EngineParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
The LayerParameterBase is the base class for all other layer specific parameters.
Stores the parameters used by the SerfLayer
static new SerfParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
SerfParameter()
Constructor for the parameter.
double threshold
Specifies the max threshold value used in exp functions.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
bool useCudnn()
Queries whether or not to use NVIDIA's cuDnn.
string useCaffeReason()
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.param.beta parameters are used by the MyCaffe.layer.beta layers.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12