MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MishParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.beta
9{
18 [Serializable]
19 [TypeConverter(typeof(ExpandableObjectConverter))]
21 {
22 double m_dfThreshold = 20;
23 int m_nMethod = 0;
24
27 : base()
28 {
29 }
30
35 public string useCaffeReason()
36 {
37 return "Currenly only CAFFE supported.";
38 }
39
45 public bool useCudnn()
46 {
47 return false;
48 }
49
56 [Description("Specifies the max threshold value used in exp functions.")]
57 public double threshold
58 {
59 get { return m_dfThreshold; }
60 set { m_dfThreshold = value; }
61 }
62
66 public int method
67 {
68 get { return m_nMethod; }
69 set { m_nMethod = value; }
70 }
71
73 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
74 {
75 RawProto proto = RawProto.Parse(br.ReadString());
76 MishParameter p = FromProto(proto);
77
78 if (!bNewInstance)
79 Copy(p);
80
81 return p;
82 }
83
85 public override void Copy(LayerParameterBase src)
86 {
87 base.Copy(src);
88
89 if (src is MishParameter)
90 {
92 m_dfThreshold = p.m_dfThreshold;
93 m_nMethod = p.m_nMethod;
94 }
95 }
96
98 public override LayerParameterBase Clone()
99 {
101 p.Copy(this);
102 return p;
103 }
104
106 public override RawProto ToProto(string strName)
107 {
108 RawProto rpBase = base.ToProto("engine");
109 RawProtoCollection rgChildren = new RawProtoCollection();
110
111 rgChildren.Add(rpBase.Children);
112
113 if (threshold != 0)
114 rgChildren.Add("threshold", threshold.ToString());
115
116 if (method != 0)
117 rgChildren.Add("method", threshold.ToString());
118
119 return new RawProto(strName, "", rgChildren);
120 }
121
127 public static new MishParameter FromProto(RawProto rp)
128 {
129 string strVal;
131
133
134 if ((strVal = rp.FindValue("threshold")) != null)
135 p.threshold = ParseDouble(strVal);
136
137 if ((strVal = rp.FindValue("method")) != null)
138 p.method = int.Parse(strVal);
139
140 return p;
141 }
142 }
143}
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 MishLayer
bool useCudnn()
Queries whether or not to use NVIDIA's cuDnn.
double threshold
Specifies the max threshold value used in exp functions.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
string useCaffeReason()
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
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.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
static new MishParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
MishParameter()
Constructor for the parameter.
int method
Specifies the method used for backward computation, where method = 0 uses the default scalled method,...
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