MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
SwishParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
16 [Serializable]
17 [TypeConverter(typeof(ExpandableObjectConverter))]
19 {
20 double m_dfBeta = 1;
21
24 : base()
25 {
26 }
27
32 public string useCaffeReason()
33 {
34 if (engine == Engine.CAFFE)
35 return "The engine setting is set on CAFFE.";
36
37 return "";
38 }
39
44 public bool useCudnn()
45 {
46 if (engine == EngineParameter.Engine.CAFFE)
47 return false;
48
49 return true;
50 }
51
55 [Description("Specifies the Beta parameter for the Swish activation function.")]
56 public double beta
57 {
58 get { return m_dfBeta; }
59 set { m_dfBeta = value; }
60 }
61
63 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
64 {
65 RawProto proto = RawProto.Parse(br.ReadString());
66 SwishParameter p = FromProto(proto);
67
68 if (!bNewInstance)
69 Copy(p);
70
71 return p;
72 }
73
75 public override void Copy(LayerParameterBase src)
76 {
77 base.Copy(src);
78
79 if (src is SwishParameter)
80 {
82 m_dfBeta = p.m_dfBeta;
83 }
84 }
85
87 public override LayerParameterBase Clone()
88 {
90 p.Copy(this);
91 return p;
92 }
93
99 public override RawProto ToProto(string strName)
100 {
101 RawProto rpBase = base.ToProto("engine");
102 RawProtoCollection rgChildren = new RawProtoCollection();
103
104 rgChildren.Add(rpBase.Children);
105
106 if (beta != 0)
107 rgChildren.Add("beta", beta.ToString());
108
109 return new RawProto(strName, "", rgChildren);
110 }
111
117 public static new SwishParameter FromProto(RawProto rp)
118 {
119 string strVal;
121
123
124 if ((strVal = rp.FindValue("beta")) != null)
125 p.beta = ParseDouble(strVal);
126
127 return p;
128 }
129 }
130}
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...
Engine engine
Specifies the Engine in use.
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.
Stores the parameters used by the SwishLayer
static new SwishParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
double beta
Specifies the beta value for the Swish activation function.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
bool useCudnn()
Queries whether or not to use NVIDIA's cuDnn.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
string useCaffeReason()
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
SwishParameter()
Constructor for the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
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