MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
PositionalEncoderParameter.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 uint m_nEmbed = 192; // d_model
18 uint m_nBlockSize = 128;
19
22 {
23 }
24
28 public uint embed
29 {
30 get { return m_nEmbed; }
31 set { m_nEmbed = value; }
32 }
33
37 public uint block_size
38 {
39 get { return m_nBlockSize; }
40 set { m_nBlockSize = value; }
41 }
42
44 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
45 {
46 RawProto proto = RawProto.Parse(br.ReadString());
48
49 if (!bNewInstance)
50 Copy(p);
51
52 return p;
53 }
54
56 public override void Copy(LayerParameterBase src)
57 {
59
60 m_nEmbed = p.embed;
61 m_nBlockSize = p.block_size;
62 }
63
65 public override LayerParameterBase Clone()
66 {
68 p.Copy(this);
69 return p;
70 }
71
77 public override RawProto ToProto(string strName)
78 {
79 RawProtoCollection rgChildren = new RawProtoCollection();
80
81 rgChildren.Add("embed", embed.ToString());
82 rgChildren.Add("block_size", block_size.ToString());
83
84 return new RawProto(strName, "", rgChildren);
85 }
86
93 {
94 string strVal;
96
97 if ((strVal = rp.FindValue("embed")) != null)
98 p.embed = uint.Parse(strVal);
99
100 if ((strVal = rp.FindValue("block_size")) != null)
101 p.block_size = uint.Parse(strVal);
102
103 return p;
104 }
105 }
106}
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 PositionalEncoderLayer.
override void Copy(LayerParameterBase src)
Copy on parameter to another.
static PositionalEncoderParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
PositionalEncoderParameter()
Constructor for the parameter.
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