MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
EluParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
17 [Serializable]
18 [TypeConverter(typeof(ExpandableObjectConverter))]
20 {
21 double m_dfAlpha = 1.0;
22
24 public EluParameter()
25 : base()
26 {
27 }
28
33 public string useCaffeReason()
34 {
35 if (engine == Engine.CAFFE)
36 return "The engine setting is set on CAFFE.";
37
38 if (m_dfAlpha != 1.0)
39 return "cuDnn only supports Alpha = 1.0";
40
41 return "";
42 }
43
48 public bool useCudnn()
49 {
50 if (engine == EngineParameter.Engine.CAFFE || m_dfAlpha != 1.0)
51 return false;
52
53 return true;
54 }
55
62 [Description("Described in 'Clevert, D. -A, Unterthiner, T., & Hochreiter, S. (2015). Fast and Accurate Deep Network Learning from Exponential Linear Units (ELUs). arXiv")]
63 public double alpha
64 {
65 get { return m_dfAlpha; }
66 set { m_dfAlpha = value; }
67 }
68
70 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
71 {
72 RawProto proto = RawProto.Parse(br.ReadString());
73 EluParameter p = FromProto(proto);
74
75 if (!bNewInstance)
76 Copy(p);
77
78 return p;
79 }
80
82 public override void Copy(LayerParameterBase src)
83 {
84 base.Copy(src);
85
86 if (src is EluParameter)
87 {
89 m_dfAlpha = p.m_dfAlpha;
90 }
91 }
92
94 public override LayerParameterBase Clone()
95 {
96 EluParameter p = new EluParameter();
97 p.Copy(this);
98 return p;
99 }
100
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 (alpha != 1.0)
114 rgChildren.Add("alpha", alpha.ToString());
115
116 return new RawProto(strName, "", rgChildren);
117 }
118
124 public static new EluParameter FromProto(RawProto rp)
125 {
126 string strVal;
127 EluParameter p = new EluParameter();
128
130
131 if ((strVal = rp.FindValue("alpha")) != null)
132 p.alpha = ParseDouble(strVal);
133
134 return p;
135 }
136 }
137}
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 the parameters for the EluLayer.
Definition: EluParameter.cs:20
override void Copy(LayerParameterBase src)
Copy on parameter to another.
Definition: EluParameter.cs:82
EluParameter()
Constructor for the parameter.
Definition: EluParameter.cs:24
bool useCudnn()
Queries whether or not to use NVIDIA's cuDnn.
Definition: EluParameter.cs:48
string useCaffeReason()
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
Definition: EluParameter.cs:33
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: EluParameter.cs:70
double alpha
Described in Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs) by Clevert,...
Definition: EluParameter.cs:64
static new EluParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
Definition: EluParameter.cs:94
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
Specifies whether to use the NVIDIA cuDnn version or Caffe version of a given forward/backward operat...
Engine engine
Specifies the Engine in use.
EngineParameter()
Constructor for the parameter.
static EngineParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
Engine
Defines the type of engine to use.
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