MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
GeluParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
8namespace MyCaffe.param.gpt
9{
13 [Serializable]
14 [TypeConverter(typeof(ExpandableObjectConverter))]
16 {
17 bool m_bEnableBertVersion = false;
18
21 {
22 }
23
27 [Description("Specifies to use the special BERT version used in GPT models.")]
29 {
30 get { return m_bEnableBertVersion; }
31 set { m_bEnableBertVersion = value; }
32 }
33
35 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
36 {
37 RawProto proto = RawProto.Parse(br.ReadString());
38 GeluParameter p = FromProto(proto);
39
40 if (!bNewInstance)
41 Copy(p);
42
43 return p;
44 }
45
47 public override void Copy(LayerParameterBase src)
48 {
50
51 m_bEnableBertVersion = p.enable_bert_version;
52 }
53
55 public override LayerParameterBase Clone()
56 {
58 p.Copy(this);
59 return p;
60 }
61
67 public override RawProto ToProto(string strName)
68 {
69 RawProtoCollection rgChildren = new RawProtoCollection();
70
71 rgChildren.Add("enable_bert_version", enable_bert_version.ToString());
72
73 return new RawProto(strName, "", rgChildren);
74 }
75
82 {
83 string strVal;
85
86 if ((strVal = rp.FindValue("enable_bert_version")) != null)
87 p.enable_bert_version = bool.Parse(strVal);
88
89 return p;
90 }
91 }
92}
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
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the GeluLayer.
bool enable_bert_version
Specifies to use the special BERT version used in GPT models.
static GeluParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
GeluParameter()
Constructor for the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12