MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
LSTMSimpleLayer.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using MyCaffe.basecode;
6using MyCaffe.common;
7using MyCaffe.param;
8using MyCaffe.fillers;
9
10namespace MyCaffe.layers
11{
29 public class LSTMSimpleLayer<T> : Layer<T>
30 {
31 int m_nI; // input dimension.
32 int m_nH; // number of hidden units.
33 int m_nT; // length of sequence.
34 int m_nN; // batch size.
35
36 double m_dfClippingThreshold; // threshold for clipped gradient.
37 Blob<T> m_blobBiasMultiplier;
38
39 Blob<T> m_blobTop; // Output values.
40 Blob<T> m_blobCell; // Memory cell.
41 Blob<T> m_blobPreGate; // gate values before nonlinearity.
42 Blob<T> m_blobGate; // gate values after nonlinearity.
43
44 Blob<T> m_blob_C_0; // previous cell state value.
45 Blob<T> m_blob_H_0; // previous hidden activation value.
46 Blob<T> m_blob_C_T; // next cell state value.
47 Blob<T> m_blob_H_T; // next hidden activation value.
48
49 // Intermediate values.
50 Blob<T> m_blob_H_to_Gate;
51 Blob<T> m_blob_H_to_H;
52
76 : base(cuda, log, p)
77 {
78 m_type = LayerParameter.LayerType.LSTM_SIMPLE;
79
80 m_blobBiasMultiplier = new Blob<T>(m_cuda, m_log);
81 m_blobBiasMultiplier.Name = m_param.name + " biasmult";
82 m_blobTop = new Blob<T>(m_cuda, m_log);
83 m_blobTop.Name = m_param.name + " top";
84 m_blobCell = new Blob<T>(m_cuda, m_log);
85 m_blobCell.Name = m_param.name + " cell";
86 m_blobPreGate = new Blob<T>(m_cuda, m_log);
87 m_blobPreGate.Name = m_param.name + " pregate";
88 m_blobGate = new Blob<T>(m_cuda, m_log);
89 m_blobGate.Name = m_param.name + " gate";
90 m_blob_C_0 = new Blob<T>(m_cuda, m_log);
91 m_blob_C_0.Name = m_param.name + " c_0";
92 m_blob_H_0 = new Blob<T>(m_cuda, m_log);
93 m_blob_H_0.Name = m_param.name + " h_0";
94 m_blob_C_T = new Blob<T>(m_cuda, m_log);
95 m_blob_C_T.Name = m_param.name + " c_t";
96 m_blob_H_T = new Blob<T>(m_cuda, m_log);
97 m_blob_H_T.Name = m_param.name + " h_t";
98 m_blob_H_to_Gate = new Blob<T>(m_cuda, m_log);
99 m_blob_H_to_Gate.Name = m_param.name + "h_to_gate";
100 m_blob_H_to_H = new Blob<T>(m_cuda, m_log);
101 m_blob_H_to_H.Name = m_param.name + " h_to_h";
102 }
103
105 protected override void dispose()
106 {
107 base.dispose();
108
109 m_blobBiasMultiplier.Dispose();
110 m_blobTop.Dispose();
111 m_blobCell.Dispose();
112 m_blobPreGate.Dispose();
113 m_blobGate.Dispose();
114 m_blob_C_0.Dispose();
115 m_blob_C_T.Dispose();
116 m_blob_H_0.Dispose();
117 m_blob_H_T.Dispose();
118 m_blob_H_to_Gate.Dispose();
119 m_blob_H_to_H.Dispose();
120 }
121
123 protected override void setup_internal_blobs(BlobCollection<T> col)
124 {
125 if (col.Count > 0)
126 return;
127
128 col.Add(m_blobBiasMultiplier);
129 col.Add(m_blobTop);
130 col.Add(m_blobCell);
131 col.Add(m_blobPreGate);
132 col.Add(m_blobGate);
133 col.Add(m_blob_C_0);
134 col.Add(m_blob_H_0);
135 col.Add(m_blob_C_T);
136 col.Add(m_blob_H_T);
137 col.Add(m_blob_H_to_Gate);
138 col.Add(m_blob_H_to_H);
139 }
140
146 public override bool ReInitializeParameters(WEIGHT_TARGET target)
147 {
148 base.ReInitializeParameters(target);
149
150 if (target == WEIGHT_TARGET.BOTH || target == WEIGHT_TARGET.WEIGHTS)
151 {
153 weight_filler.Fill(m_colBlobs[0]);
154 weight_filler.Fill(m_colBlobs[1]);
155 }
156
157 if (target == WEIGHT_TARGET.BOTH || target == WEIGHT_TARGET.BIAS)
158 {
160 bias_filler.Fill(m_colBlobs[2]);
161
162 // Initialize the bias for the forget gate to 5.0 as described in the
163 // Clockwork RNN paper:
164 // [1] Koutnik, J., Greff, K., Gomez, F., Schmidhuber, J., 'A Clockwork RNN', 2014"
166 {
167 double[] rgBias = convertD(m_colBlobs[2].mutable_cpu_data);
168
169 for (int i = m_nH; i < 2 * m_nH; i++)
170 {
171 rgBias[i] = 5.0;
172 }
173
174 m_colBlobs[2].mutable_cpu_data = convert(rgBias);
175 }
176 }
177
178 return true;
179 }
180
181
187 public override void LayerSetUp(BlobCollection<T> colBottom, BlobCollection<T> colTop)
188 {
189 m_dfClippingThreshold = m_param.lstm_simple_param.clipping_threshold;
190 m_nN = (int)m_param.lstm_simple_param.batch_size; // batch size.
191 m_nH = (int)m_param.lstm_simple_param.num_output; // number of hidden units.
192 m_nI = (int)(colBottom[0].count() / colBottom[0].num); // input dimension.
193
194 // Check if we need to set up the weights.
195 if (m_colBlobs.Count > 0)
196 {
197 m_log.WriteLine("Skipping parameter initialization.");
198 }
199 else
200 {
202
205
206 // input-to-hidden weights
207 // Initialize the weight.
208 List<int> rgShape1 = new List<int>() { 4 * m_nH, m_nI };
209 Blob<T> blobWeights_I_H = new Blob<T>(m_cuda, m_log);
210 blobWeights_I_H.Name = m_param.name + " weights I to H";
211 blobWeights_I_H.type = BLOB_TYPE.WEIGHT;
212
213 if (!shareParameter(blobWeights_I_H, rgShape1))
214 {
215 blobWeights_I_H.Reshape(rgShape1);
216 weight_filler.Fill(blobWeights_I_H);
217 }
218 m_colBlobs.Add(blobWeights_I_H);
219
220 // hidden-to-hidden weights
221 // Initialize the weight.
222 List<int> rgShape2 = new List<int>() { 4 * m_nH, m_nH };
223 Blob<T> blobWeights_H_H = new Blob<T>(m_cuda, m_log);
224 blobWeights_H_H.Name = m_param.name + " weights H to H";
225 blobWeights_H_H.type = BLOB_TYPE.WEIGHT;
226
227 if (!shareParameter(blobWeights_H_H, rgShape2))
228 {
229 blobWeights_H_H.Reshape(rgShape2);
230 weight_filler.Fill(blobWeights_H_H);
231 }
232 m_colBlobs.Add(blobWeights_H_H);
233
234 // If necessary, initialize and fill the bias term.
235 List<int> rgShape3 = new List<int>() { 4 * m_nH };
236 Blob<T> blobBias = new Blob<T>(m_cuda, m_log);
237 blobBias.Name = m_param.name + " bias weights";
238 blobBias.type = BLOB_TYPE.WEIGHT;
239
240 if (!shareParameter(blobBias, rgShape3))
241 {
242 blobBias.Reshape(rgShape3);
243 bias_filler.Fill(blobBias);
244 }
245 m_colBlobs.Add(blobBias);
246
247 // Initialize the bias for the forget gate to 5.0 as described in the
248 // Clockwork RNN paper:
249 // [1] Koutnik, J., Greff, K., Gomez, F., Schmidhuber, J., 'A Clockwork RNN', 2014"
251 {
252 double[] rgBias = convertD(blobBias.mutable_cpu_data);
253
254 for (int i=m_nH; i<2*m_nH; i++)
255 {
256 rgBias[i] = 5.0;
257 }
258
259 blobBias.mutable_cpu_data = convert(rgBias);
260 }
261 }
262
263 m_rgbParamPropagateDown = new DictionaryMap<bool>(m_colBlobs.Count, true);
264
265 List<int> rgCellShape = new List<int>() { m_nN, m_nH };
266 m_blob_C_0.Reshape(rgCellShape);
267 m_blob_H_0.Reshape(rgCellShape);
268 m_blob_C_T.Reshape(rgCellShape);
269 m_blob_H_T.Reshape(rgCellShape);
270 m_blob_H_to_H.Reshape(rgCellShape);
271
272 List<int> rgGateShape = new List<int>() { m_nN, 4, m_nH };
273 m_blob_H_to_Gate.Reshape(rgGateShape);
274 }
275
281 public override void Reshape(BlobCollection<T> colBottom, BlobCollection<T> colTop)
282 {
284 {
285 m_nN = colBottom[0].num;
286 m_bNetReshapeRequest = false;
287 }
288
289 // Figure out the dimensions.
290 m_nT = colBottom[0].num / m_nN; // length of sequence.
291 m_log.CHECK_EQ(colBottom[0].num % m_nN, 0, "The inputs size should be a multiple of the batch size.");
292 m_log.CHECK_EQ(colBottom[0].count() / m_nT / m_nN, m_nI, "The input size is incompatible with inner product parameters.");
293
294 List<int> rgOriginalTopShape = new List<int>() { m_nT * m_nN, m_nH };
295 colTop[0].Reshape(rgOriginalTopShape);
296
297 // Gate initialization.
298 List<int> rgGateShape = new List<int>() { m_nT, m_nN, 4, m_nH };
299 m_blobPreGate.Reshape(rgGateShape);
300 m_blobGate.Reshape(rgGateShape);
301 m_blob_H_to_Gate.Reshape(rgGateShape);
302
303 List<int> rgTopShape = new List<int>() { m_nT, m_nN, m_nH };
304 m_blobCell.Reshape(rgTopShape);
305 m_blobTop.Reshape(rgTopShape);
306 m_blobTop.ShareData(colTop[0]);
307 m_blobTop.ShareDiff(colTop[0]);
308
309 // Setup the bias multipler.
310 List<int> rgMultiplierShape = new List<int>() { m_nN * m_nT };
311 m_blobBiasMultiplier.Reshape(rgMultiplierShape);
312 m_blobBiasMultiplier.SetData(1.0);
313
314 List<int> rgCellShape = new List<int>() { m_nN, m_nH };
315 m_blob_C_0.Reshape(rgCellShape);
316 m_blob_H_0.Reshape(rgCellShape);
317 m_blob_C_T.Reshape(rgCellShape);
318 m_blob_H_T.Reshape(rgCellShape);
319 m_blob_H_to_H.Reshape(rgCellShape);
320 }
321
332 protected override void forward(BlobCollection<T> colBottom, BlobCollection<T> colTop)
333 {
334 m_log.CHECK_EQ(colTop[0].gpu_data, m_blobTop.gpu_data, "The top[0].gpu_data should equal the blobTop.gpu_data.");
335 long hTopData = m_blobTop.mutable_gpu_data;
336 long hBottomData = colBottom[0].gpu_data;
337 long hClipData = 0;
338
339 if (colBottom.Count > 1)
340 {
341 hClipData = colBottom[1].gpu_data;
342 m_log.CHECK_EQ(colBottom[1].num, colBottom[1].count(), "The bottom[1].num should equal the bottom[1].count.");
343 }
344
345 long hWeight_i = m_colBlobs[0].gpu_data;
346 long hWeight_h = m_colBlobs[1].gpu_data;
347 long hBias = m_colBlobs[2].gpu_data;
348 long hPreGateData = m_blobPreGate.mutable_gpu_data;
349 long hGateData = m_blobGate.mutable_gpu_data;
350 long hCellData = m_blobCell.mutable_gpu_data;
351 long hHtoGateData = m_blob_H_to_Gate.mutable_gpu_data;
352
353 // Initialize previous state.
354 if (hClipData != 0)
355 {
356 m_cuda.copy(m_blob_C_0.count(), m_blob_C_T.gpu_data, m_blob_C_0.mutable_gpu_data);
357 m_cuda.copy(m_blob_H_0.count(), m_blob_H_T.gpu_data, m_blob_H_0.mutable_gpu_data);
358 }
359 else
360 {
361 m_blob_C_0.SetData(0.0);
362 m_blob_H_0.SetData(0.0);
363 }
364
365 // Compute input to hidden forward propagation.
366 m_cuda.gemm(false, true, m_nT * m_nN, 4 * m_nH, m_nI, m_tOne, hBottomData, hWeight_i, m_tZero, hPreGateData);
367 m_cuda.gemm(false, false, m_nT * m_nN, 4 * m_nH, 1, m_tOne, m_blobBiasMultiplier.gpu_data, hBias, m_tOne, hPreGateData);
368
369 // Compute recurrent forward propagation
370 for (int t = 0; t < m_nT; t++)
371 {
372 int nTopOffset = m_blobTop.offset(t);
373 int nCellOffset = m_blobCell.offset(t);
374 int nPreGateOffset = m_blobPreGate.offset(t);
375 int nGateOffset = m_blobGate.offset(t);
376 int nClipOffset = (hClipData != 0) ? colBottom[1].offset(t) : 0;
377 int nHT1Offset;
378 long hHT1Data;
379 int nCT1Offset;
380 long hCT1Data;
381
382 if (t == 0)
383 {
384 hHT1Data = m_blob_H_0.gpu_data;
385 nHT1Offset = 0;
386 hCT1Data = m_blob_C_0.gpu_data;
387 nCT1Offset = 0;
388 }
389 else
390 {
391 hHT1Data = m_blob_H_T.gpu_data;
392 nHT1Offset = -m_blobTop.offset(1);
393 hCT1Data = m_blob_C_T.gpu_data;
394 nCT1Offset = -m_blobCell.offset(1);
395 }
396
397 m_cuda.lstm_fwd(t,
398 m_nN,
399 m_nH,
400 m_nI,
401 hWeight_h,
402 hWeight_i,
403 hClipData,
404 nClipOffset,
405 hTopData, // h_t data
406 nTopOffset, // h_t offset
407 hCellData, // c_t data
408 nCellOffset, // c_t offset
409 hPreGateData,
410 nPreGateOffset,
411 hGateData,
412 nGateOffset,
413 hHT1Data,
414 nHT1Offset,
415 hCT1Data,
416 nCT1Offset,
417 hHtoGateData);
418 }
419
420 // Preserve cell state and output value for truncated BPTT
421 m_cuda.copy(m_nN * m_nH, hCellData, m_blob_C_T.mutable_gpu_data, m_blobCell.offset(m_nT - 1));
422 m_cuda.copy(m_nN * m_nH, hTopData, m_blob_H_T.mutable_gpu_data, m_blobTop.offset(m_nT - 1));
423 }
424
435 protected override void backward(BlobCollection<T> colTop, List<bool> rgbPropagateDown, BlobCollection<T> colBottom)
436 {
437 long hTopData = m_blobTop.gpu_data;
438 long hBottomData = colBottom[0].gpu_data;
439 long hClipData = 0;
440
441 if (colBottom.Count > 1)
442 {
443 hClipData = colBottom[1].gpu_data;
444 m_log.CHECK_EQ(colBottom[1].num, colBottom[1].count(), "The bottom[1].num should equal the bottom[1].count.");
445 }
446
447 long hWeight_i = m_colBlobs[0].gpu_data;
448 long hWeight_h = m_colBlobs[1].gpu_data;
449 long hGateData = m_blobGate.gpu_data;
450 long hCellData = m_blobCell.gpu_data;
451
452 long hTopDiff = m_blobTop.mutable_gpu_diff;
453 long hPreGateDiff = m_blobPreGate.mutable_gpu_diff;
454 long hGateDiff = m_blobGate.mutable_gpu_diff;
455 long hCellDiff = m_blobCell.mutable_gpu_diff;
456 long hHtoHData = m_blob_H_to_H.mutable_gpu_data;
457
458 m_cuda.copy(m_nN * m_nH, m_blob_C_T.gpu_diff, hCellDiff, 0, m_blobCell.offset(m_nT - 1));
459
460 for (int t = m_nT - 1; t >= 0; t--)
461 {
462 int nTopOffset = m_blobTop.offset(t);
463 int nCellOffset = m_blobCell.offset(t);
464 int nGateOffset = m_blobGate.offset(t);
465 int nPreGateOffset = m_blobPreGate.offset(t);
466 int nClipOffset = (hClipData == 0) ? 0 : colBottom[1].offset(t);
467 int nCT1Offset;
468 long hCT1Data;
469 int nDHT1Offset;
470 long hDHT1Diff;
471 int nDCT1Offset;
472 long hDCT1Diff;
473
474 if (t == 0)
475 {
476 nCT1Offset = 0;
477 hCT1Data = m_blob_C_0.gpu_data;
478 nDHT1Offset = 0;
479 hDHT1Diff = m_blob_H_0.mutable_gpu_diff;
480 nDCT1Offset = 0;
481 hDCT1Diff = m_blob_C_0.mutable_gpu_diff;
482 }
483 else
484 {
485 nCT1Offset = m_blobCell.offset(t - 1);
486 hCT1Data = hCellData;
487 nDHT1Offset = m_blobTop.offset(t - 1);
488 hDHT1Diff = hTopDiff;
489 nDCT1Offset = m_blobCell.offset(t - 1);
490 hDCT1Diff = hCellDiff;
491 }
492
493 m_cuda.lstm_bwd(t,
494 m_nN,
495 m_nH,
496 m_nI,
497 m_dfClippingThreshold,
498 hWeight_h,
499 hClipData,
500 nClipOffset,
501 hTopDiff,
502 nTopOffset,
503 hCellData,
504 hCellDiff,
505 nCellOffset,
506 hPreGateDiff,
507 nPreGateOffset,
508 hGateData,
509 hGateDiff,
510 nGateOffset,
511 hCT1Data,
512 nCT1Offset,
513 hDHT1Diff,
514 nDHT1Offset,
515 hDCT1Diff,
516 nDCT1Offset,
517 hHtoHData);
518 }
519
521 {
522 // Gradient w.r.t input-to-hidden weight
523 m_cuda.gemm(true, false, 4 * m_nH, m_nI, m_nT * m_nN, m_tOne, hPreGateDiff, hBottomData, m_tOne, m_colBlobs[0].mutable_gpu_diff);
524 }
525
527 {
528 // Gradient w.r.t. hidden-to-hidden weight
529 m_cuda.gemm(true, false, 4 * m_nH, m_nH, (m_nT - 1) * m_nN, m_tOne, hPreGateDiff, hTopData, m_tOne, m_colBlobs[1].mutable_gpu_diff, m_blobPreGate.offset(1));
530
531 // Add gradient from previous time-step.
532 m_cuda.gemm(true, false, 4 * m_nH, m_nH, 1, m_tOne, hPreGateDiff, m_blob_H_0.gpu_data, m_tOne, m_colBlobs[1].mutable_gpu_diff);
533 }
534
536 {
537 // Gradient w.r.t. bias.
538 m_cuda.gemv(true, m_nT * m_nN, 4 * m_nH, m_tOne, hPreGateDiff, m_blobBiasMultiplier.gpu_data, m_tOne, m_colBlobs[2].mutable_gpu_diff);
539 }
540
541 if (rgbPropagateDown[0])
542 {
543 // Gradient w.r.t. bottom data.
544 m_cuda.gemm(false, false, m_nT * m_nN, m_nI, 4 * m_nH, m_tOne, hPreGateDiff, hWeight_i, m_tZero, colBottom[0].mutable_gpu_diff);
545 }
546 }
547 }
548}
The Log class provides general output in text form.
Definition: Log.cs:13
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
Definition: Log.cs:80
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
Definition: Log.cs:239
The BlobCollection contains a list of Blobs.
void Add(Blob< T > b)
Add a new Blob to the collection.
int Count
Returns the number of items in the collection.
void Reshape(int[] rgShape)
Reshapes all blobs in the collection to the given shape.
The Blob is the main holder of data that moves through the Layers of the Net.
Definition: Blob.cs:25
void SetData(T[] rgData, int nCount=-1, bool bSetCount=true)
Sets a number of items within the Blob's data.
Definition: Blob.cs:1922
void ShareData(Blob< T > b)
Set the data to point to the data of the other blob – useful in Layers which simply perform a copy in...
Definition: Blob.cs:1813
long mutable_gpu_diff
Returns the diff GPU handle used by the CudaDnn connection.
Definition: Blob.cs:1555
long mutable_gpu_data
Returns the data GPU handle used by the CudaDnn connection.
Definition: Blob.cs:1487
T[] mutable_cpu_data
Get data from the GPU and bring it over to the host, or Set data from the Host and send it over to th...
Definition: Blob.cs:1461
void Reshape(int nNum, int nChannels, int nHeight, int nWidth, bool? bUseHalfSize=null)
DEPRECIATED; use
Definition: Blob.cs:442
BLOB_TYPE type
Returns the BLOB_TYPE of the Blob.
Definition: Blob.cs:2761
int count()
Returns the total number of items in the Blob.
Definition: Blob.cs:739
void ShareDiff(Blob< T > b)
Set the diff to point to the diff of the other blob – useful in Layers which simply perform a copy in...
Definition: Blob.cs:1832
string Name
Get/set the name of the Blob.
Definition: Blob.cs:2184
int offset(int n, int c=0, int h=0, int w=0)
Returns the flat offset given the number, channel, height and width.
Definition: Blob.cs:850
long gpu_diff
Returns the diff GPU handle used by the CudaDnn connection.
Definition: Blob.cs:1541
virtual void Dispose(bool bDisposing)
Releases all resources used by the Blob (including both GPU and Host).
Definition: Blob.cs:402
long gpu_data
Returns the data GPU handle used by the CudaDnn connection.
Definition: Blob.cs:1479
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
Abstract Filler class used to fill blobs with values.
Definition: Filler.cs:19
void Fill(Blob< T > b)
Fill the blob with values based on the actual filler used.
Definition: Filler.cs:50
static Filler< T > Create(CudaDnn< T > cuda, Log log, FillerParameter p)
Create a new Filler instance.
Definition: Filler.cs:79
[DEPRECIATED - use LSTMAttentionLayer instead with enable_attention = false] The LSTMSimpleLayer is a...
override void setup_internal_blobs(BlobCollection< T > col)
Derivative layers should add all internal blobws to the 'col' provided.
override bool ReInitializeParameters(WEIGHT_TARGET target)
Re-initialize the parameters of the layer.
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Forward computation.
override void dispose()
Releases all GPU and host resources used by the Layer.
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Computes the error gradient w.r.t. the inputs.
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Reshape the bottom (input) and top (output) blobs.
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
LSTMSimpleLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The LSTMSimpleLayer constructor.
An interface for the units of computation which can be composed into a Net.
Definition: Layer.cs:31
Log m_log
Specifies the Log for output.
Definition: Layer.cs:43
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
Definition: Layer.cs:47
void convert(BlobCollection< T > col)
Convert a collection of blobs from / to half size.
Definition: Layer.cs:535
T m_tZero
Specifies a generic type equal to 0.0.
Definition: Layer.cs:76
T m_tOne
Specifies a generic type equal to 1.0.
Definition: Layer.cs:72
bool shareParameter(Blob< T > b, List< int > rgMinShape, bool bAllowEndsWithComparison=false)
Attempts to share a parameter Blob if another parameter Blob with the same name and accpetable size i...
Definition: Layer.cs:1152
double convertD(T df)
Converts a generic to a double value.
Definition: Layer.cs:1349
CudaDnn< T > m_cuda
Specifies the CudaDnn connection to Cuda.
Definition: Layer.cs:39
LayerParameter.LayerType m_type
Specifies the Layer type.
Definition: Layer.cs:35
BlobCollection< T > m_colBlobs
Specifies the learnable parameter Blobs of the Layer.
Definition: Layer.cs:55
DictionaryMap< bool > m_rgbParamPropagateDown
Specifies whether or not to compute the learnable diff of each parameter Blob.
Definition: Layer.cs:63
bool m_bNetReshapeRequest
Specifies whether the reshape is requested from a Net.Reshape call or not.
Definition: Layer.cs:104
double clipping_threshold
Specifies the gradient clipping threshold, default = 0.0 (i.e. no clipping).
FillerParameter weight_filler
Specifies the filler parameters for the weight filler.
uint num_output
Specifies the number of outputs for the layer.
FillerParameter bias_filler
Specifies the filler parameters for the bias filler.
uint batch_size
Specifies the batch size, default = 1.
bool enable_clockwork_forgetgate_bias
When enabled, the forget gate bias is set to 5.0.
Specifies the base parameter for all layers.
string name
Specifies the name of this LayerParameter.
LSTMSimpleParameter lstm_simple_param
[DEPRECIATED] Returns the parameter set when initialized with LayerType.LSTM_SIMPLE
LayerType
Specifies the layer type.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
BLOB_TYPE
Defines the tpe of data held by a given Blob.
Definition: Interfaces.cs:62
WEIGHT_TARGET
Defines the type of weight to target in re-initializations.
Definition: Interfaces.cs:38
The MyCaffe.fillers namespace contains all fillers including the Filler class.
The MyCaffe.layers namespace contains all layers that have a solidified code base,...
Definition: LayerFactory.cs:15
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