MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
VarSetLnetParameter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
6using MyCaffe.basecode;
7using static MyCaffe.param.tft.GluParameter;
8
9namespace MyCaffe.param.tft
10{
24 [Serializable]
25 [TypeConverter(typeof(ExpandableObjectConverter))]
27 {
28 int m_nNumInputs;
29 int m_nInputDim;
30 int m_nHiddenDim;
31 float m_fDropout = 0.05f;
32 int? m_nContextDim = null;
33 bool m_bBatchFirst = true;
34 FillerParameter m_fillerParam_weights = new FillerParameter("xavier");
35 FillerParameter m_fillerParam_bias = new FillerParameter("constant", 0.1);
36 int m_nAxis = 1;
37
40 {
41 }
42
46 [Description("Specifies the quantity of input variables, including both numeric and categorical for the relevant channel.")]
47 public int num_inputs
48 {
49 get { return m_nNumInputs; }
50 set { m_nNumInputs = value; }
51 }
52
56 [Description("Specifies the attribute/embedding dimension of the input, associated witht he 'state_size' of the model.")]
57 public int input_dim
58 {
59 get { return m_nInputDim; }
60 set { m_nInputDim = value; }
61 }
62
66 [Description("Specifies the embedding width of the output.")]
67 public int hidden_dim
68 {
69 get { return m_nHiddenDim; }
70 set { m_nHiddenDim = value; }
71 }
72
76 [Description("Specifies the embedding width of the context signal expected to be fed as an auxiliary input (optional, can be null).")]
77 public int? context_dim
78 {
79 get { return m_nContextDim; }
80 set { m_nContextDim = value; }
81 }
82
86 [Description("Specifies the dropout ratio used with the GRNs (default = 0.05 or 5%).")]
87 public float dropout_ratio
88 {
89 get { return m_fDropout; }
90 set { m_fDropout = value; }
91 }
92
96 [Description("Specifies a boolean indicating whether the batch dimension is expected to be the first dimension of the input or not.")]
97 public bool batch_first
98 {
99 get { return m_bBatchFirst; }
100 set { m_bBatchFirst = value; }
101 }
102
106 [Category("Fillers")]
107 [Description("The filler for the weights.")]
109 {
110 get { return m_fillerParam_weights; }
111 set { m_fillerParam_weights = value; }
112 }
113
117 [Category("Fillers")]
118 [Description("The filler for the bias.")]
120 {
121 get { return m_fillerParam_bias; }
122 set { m_fillerParam_bias = value; }
123 }
124
130 [Description("Specifies the first axis to be lumped into a single inner product computation; all preceding axes are retained in the output.")]
131 public int axis
132 {
133 get { return m_nAxis; }
134 set { m_nAxis = value; }
135 }
136
138 public override object Load(System.IO.BinaryReader br, bool bNewInstance = true)
139 {
140 RawProto proto = RawProto.Parse(br.ReadString());
141 VarSelNetParameter p = FromProto(proto);
142
143 if (!bNewInstance)
144 Copy(p);
145
146 return p;
147 }
148
150 public override void Copy(LayerParameterBase src)
151 {
153
154 m_nNumInputs = p.num_inputs;
155 m_nInputDim = p.input_dim;
156 m_nHiddenDim = p.hidden_dim;
157 m_nContextDim = p.context_dim;
158 m_fDropout = p.dropout_ratio;
159 m_bBatchFirst = p.batch_first;
160 m_nAxis = p.m_nAxis;
161
162 if (p.m_fillerParam_bias != null)
163 m_fillerParam_bias = p.m_fillerParam_bias.Clone();
164
165 if (p.m_fillerParam_weights != null)
166 m_fillerParam_weights = p.m_fillerParam_weights.Clone();
167 }
168
170 public override LayerParameterBase Clone()
171 {
173 p.Copy(this);
174 return p;
175 }
176
182 public override RawProto ToProto(string strName)
183 {
184 RawProtoCollection rgChildren = new RawProtoCollection();
185
186 rgChildren.Add("input_dim", input_dim.ToString());
187 rgChildren.Add("hidden_dim", hidden_dim.ToString());
188 rgChildren.Add("num_inputs", num_inputs.ToString());
189 if (context_dim.HasValue)
190 rgChildren.Add("context_dim", context_dim.Value.ToString());
191 rgChildren.Add("dropout_ratio", dropout_ratio.ToString());
192 rgChildren.Add("batch_first", batch_first.ToString());
193
194 if (weight_filler != null)
195 rgChildren.Add(weight_filler.ToProto("weight_filler"));
196
197 if (bias_filler != null)
198 rgChildren.Add(bias_filler.ToProto("bias_filler"));
199
200 rgChildren.Add("axis", axis.ToString());
201
202 return new RawProto(strName, "", rgChildren);
203 }
204
211 {
212 string strVal;
214
215 if ((strVal = rp.FindValue("input_dim")) != null)
216 p.input_dim = int.Parse(strVal);
217
218 if ((strVal = rp.FindValue("hidden_dim")) != null)
219 p.hidden_dim = int.Parse(strVal);
220
221 if ((strVal = rp.FindValue("num_inputs")) != null)
222 p.num_inputs = int.Parse(strVal);
223
224 if ((strVal = rp.FindValue("context_dim")) != null)
225 p.context_dim = int.Parse(strVal);
226
227 if ((strVal = rp.FindValue("dropout_ratio")) != null)
228 p.dropout_ratio = float.Parse(strVal);
229
230 if ((strVal = rp.FindValue("batch_first")) != null)
231 p.batch_first = bool.Parse(strVal);
232
233 RawProto rpWeightFiller = rp.FindChild("weight_filler");
234 if (rpWeightFiller != null)
235 p.weight_filler = FillerParameter.FromProto(rpWeightFiller);
236
237 RawProto rpBiasFiller = rp.FindChild("bias_filler");
238 if (rpBiasFiller != null)
239 p.bias_filler = FillerParameter.FromProto(rpBiasFiller);
240
241 if ((strVal = rp.FindValue("axis")) != null)
242 p.axis = int.Parse(strVal);
243
244 return p;
245 }
246 }
247}
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
RawProto FindChild(string strName)
Searches for a given node.
Definition: RawProto.cs:231
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 the filler parameters used to create each Filler.
static FillerParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
FillerParameter Clone()
Creates a new copy of this instance of the parameter.
The LayerParameterBase is the base class for all other layer specific parameters.
Specifies the parameters for the GluLayer (Gated Linear Unit).
Definition: GluParameter.cs:28
Specifies the parameters for the VarSelNetLayer (Variable Selection Network).
int hidden_dim
Specifies the embedding width of the output.
int? context_dim
Specifies the embedding width of the context signal expected to be fed as an auxiliary input (optiona...
FillerParameter weight_filler
The filler for the weights.
override RawProto ToProto(string strName)
Convert the parameter into a RawProto.
int num_inputs
Specifies the quantity of input variables, including both numeric and categorical for the relevant ch...
override LayerParameterBase Clone()
Creates a new copy of this instance of the parameter.
int input_dim
Specifies the attribute/embedding dimension of the input, associated witht he 'state_size' of the mod...
FillerParameter bias_filler
The filler for the bias.
float dropout_ratio
Specifies the dropout ratio used with the GRNs (default = 0.05 or 5%).
VarSelNetParameter()
Constructor for the parameter.
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.
static VarSelNetParameter FromProto(RawProto rp)
Parses the parameter from a RawProto.
int axis
Specifies the first axis to be lumped into a single inner product computations; all preceding axes ar...
bool batch_first
Specifies a boolean indicating whether the batch dimension is expected to be the first dimension of t...
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