MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
ClipParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 double m_dfMin;
18 double m_dfMax;
19
22 : base()
23 {
24 }
25
30 public string useCaffeReason()
31 {
32 return "This layer is curently only supported in Caffe.";
33 }
34
39 public bool useCudnn()
40 {
41 return false;
42 }
43
47 [Description("Specifies the min parameter for the Clip function.")]
48 public double min
49 {
50 get { return m_dfMin; }
51 set { m_dfMin = value; }
52 }
53
57 [Description("Specifies the max parameter for the Clip function.")]
58 public double max
59 {
60 get { return m_dfMax; }
61 set { m_dfMax = value; }
62 }
63
65 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
66 {
67 RawProto proto = RawProto.Parse(br.ReadString());
68 ClipParameter p = FromProto(proto);
69
70 if (!bNewInstance)
71 Copy(p);
72
73 return p;
74 }
75
77 public override void Copy(LayerParameterBase src)
78 {
79 if (src is ClipParameter)
80 {
82 m_dfMin = p.m_dfMin;
83 m_dfMax = p.m_dfMax;
84 }
85 }
86
88 public override LayerParameterBase Clone()
89 {
91 p.Copy(this);
92 return p;
93 }
94
100 public override RawProto ToProto(string strName)
101 {
102 RawProtoCollection rgChildren = new RawProtoCollection();
103
104 rgChildren.Add("min", min.ToString());
105 rgChildren.Add("max", max.ToString());
106
107 return new RawProto(strName, "", rgChildren);
108 }
109
116 {
117 string strVal;
119
121
122 if ((strVal = rp.FindValue("min")) != null)
123 p.min = ParseDouble(strVal);
124
125 if ((strVal = rp.FindValue("max")) != null)
126 p.max = ParseDouble(strVal);
127
128 return p;
129 }
130 }
131}
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
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
Stores the parameters used by the ClipLayer
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 LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
double min
Specifies the min value for the Clip activation function.
string useCaffeReason()
Returns the reason that Caffe version was used instead of NVIDIA's cuDnn.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
ClipParameter()
Constructor for the parameter.
static ClipParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
double max
Specifies the max value for the Clip activation function.
bool useCudnn()
Queries whether or not to use NVIDIA's cuDnn.
Specifies whether to use the NVIDIA cuDnn version or Caffe version of a given forward/backward operat...
static EngineParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
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