MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
CfcParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7
9{
18 [Serializable]
19 [TypeConverter(typeof(ExpandableObjectConverter))]
21 {
22 int m_nInputFeatures = 0;
23 int m_nHiddenSize = 0;
24 int m_nOutputFeatures = 0;
25 bool m_bReturnSequence = false;
26 CELL_TYPE m_cellType = CELL_TYPE.CFC;
27
31 public enum CELL_TYPE
32 {
36 CFC,
40 LTC
41 }
42
44 public CfcParameter()
45 {
46 }
47
51 [Description("Specifies the cell type to use.")]
53 {
54 get { return m_cellType; }
55 set { m_cellType = value; }
56 }
57
61 [Description("Specifies the number of input features.")]
62 public int input_features
63 {
64 get { return m_nInputFeatures; }
65 set { m_nInputFeatures = value; }
66 }
67
71 [Description("Specifies the hidden size used to size the backbone units and other internal layers.")]
72 public int hidden_size
73 {
74 get { return m_nHiddenSize; }
75 set { m_nHiddenSize = value; }
76 }
77
81 [Description("Specifies the number of output features.")]
82 public int output_features
83 {
84 get { return m_nOutputFeatures; }
85 set { m_nOutputFeatures = value; }
86 }
87
91 [Description("Specifies whether or not to return the sequence.")]
92 public bool return_sequences
93 {
94 get { return m_bReturnSequence; }
95 set { m_bReturnSequence = value; }
96 }
97
99 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
100 {
101 RawProto proto = RawProto.Parse(br.ReadString());
102 CfcParameter p = FromProto(proto);
103
104 if (!bNewInstance)
105 Copy(p);
106
107 return p;
108 }
109
111 public override void Copy(LayerParameterBase src)
112 {
113 CfcParameter p = (CfcParameter)src;
114
115 m_nInputFeatures = p.input_features;
116 m_nHiddenSize = p.hidden_size;
117 m_nOutputFeatures = p.output_features;
118 m_bReturnSequence = p.m_bReturnSequence;
119 m_cellType = p.cell_type;
120 }
121
123 public override LayerParameterBase Clone()
124 {
125 CfcParameter p = new CfcParameter();
126 p.Copy(this);
127 return p;
128 }
129
135 public override RawProto ToProto(string strName)
136 {
137 RawProtoCollection rgChildren = new RawProtoCollection();
138
139 rgChildren.Add("input_features", input_features.ToString());
140 rgChildren.Add("hidden_size", hidden_size.ToString());
141 rgChildren.Add("output_features", output_features.ToString());
142 rgChildren.Add("return_sequences", return_sequences.ToString());
143 rgChildren.Add("cell_type", cell_type.ToString());
144
145 return new RawProto(strName, "", rgChildren);
146 }
147
154 {
155 string strVal;
156 CfcParameter p = new CfcParameter();
157
158 if ((strVal = rp.FindValue("input_features")) != null)
159 p.input_features = int.Parse(strVal);
160
161 if ((strVal = rp.FindValue("hidden_size")) != null)
162 p.hidden_size = int.Parse(strVal);
163
164 if ((strVal = rp.FindValue("output_features")) != null)
165 p.output_features = int.Parse(strVal);
166
167 if ((strVal = rp.FindValue("return_sequences")) != null)
168 p.return_sequences = bool.Parse(strVal);
169
170 if ((strVal = rp.FindValue("cell_type")) != null)
171 p.cell_type = (CELL_TYPE)Enum.Parse(typeof(CELL_TYPE), strVal, true);
172
173 return p;
174 }
175 }
176}
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 used by the CfcLayer. Note, you must also fill out the CfcUnitParameter.
Definition: CfcParameter.cs:21
CELL_TYPE cell_type
Specifies the cell type to use (default = CFC).
Definition: CfcParameter.cs:53
override void Copy(LayerParameterBase src)
Copy on parameter to another.
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
CfcParameter()
Constructor for the parameter.
Definition: CfcParameter.cs:44
CELL_TYPE
Defines the cell type.
Definition: CfcParameter.cs:32
int input_features
Specifies the number of input features.
Definition: CfcParameter.cs:63
override object Load(System.IO.BinaryReader br, bool bNewInstance=true)
Load the parameter from a binary reader.
Definition: CfcParameter.cs:99
int output_features
Specifies the number of output features
Definition: CfcParameter.cs:83
int hidden_size
Specifies the hidden size used to size the backbone units and other internal layers.
Definition: CfcParameter.cs:73
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
static CfcParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
bool return_sequences
Specifies whether or not to return the sequence.
Definition: CfcParameter.cs:93
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