Logo ROOT   6.14/05
Reference Guide
ConvLayer.h
Go to the documentation of this file.
1 // @(#)root/tmva/tmva/dnn:$Id$
2 // Author: Vladimir Ilievski
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : TConvLayer *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Convolutional Deep Neural Network Layer *
12  * *
13  * Authors (alphabetical): *
14  * Vladimir Ilievski <ilievski.vladimir@live.com> - CERN, Switzerland *
15  * *
16  * Copyright (c) 2005-2015: *
17  * CERN, Switzerland *
18  * U. of Victoria, Canada *
19  * MPI-K Heidelberg, Germany *
20  * U. of Bonn, Germany *
21  * *
22  * Redistribution and use in source and binary forms, with or without *
23  * modification, are permitted according to the terms listed in LICENSE *
24  * (http://tmva.sourceforge.net/LICENSE) *
25  **********************************************************************************/
26 
27 #ifndef TMVA_CNN_CONVLAYER
28 #define TMVA_CNN_CONVLAYER
29 
30 #include "TMatrix.h"
31 
32 #include "TMVA/DNN/GeneralLayer.h"
33 #include "TMVA/DNN/Functions.h"
34 
35 #include <vector>
36 #include <iostream>
37 
38 namespace TMVA {
39 namespace DNN {
40 namespace CNN {
41 
42 template <typename Architecture_t>
43 class TConvLayer : public VGeneralLayer<Architecture_t> {
44 public:
45  using Matrix_t = typename Architecture_t::Matrix_t;
46  using Scalar_t = typename Architecture_t::Scalar_t;
47 
48 private:
49  size_t fFilterDepth; ///< The depth of the filter.
50  size_t fFilterHeight; ///< The height of the filter.
51  size_t fFilterWidth; ///< The width of the filter.
52 
53  size_t fStrideRows; ///< The number of row pixels to slid the filter each step.
54  size_t fStrideCols; ///< The number of column pixels to slid the filter each step.
55 
56  size_t fPaddingHeight; ///< The number of zero layers added top and bottom of the input.
57  size_t fPaddingWidth; ///< The number of zero layers left and right of the input.
58 
59  size_t fNLocalViewPixels; ///< The number of pixels in one local image view.
60  size_t fNLocalViews; ///< The number of local views in one image.
61 
62  Scalar_t fDropoutProbability; ///< Probability that an input is active.
63 
64  std::vector<Matrix_t> fDerivatives; ///< First fDerivatives of the activations of this layer.
65 
66  std::vector<int> fForwardIndices; ///< Vector of indices used for a fast Im2Col in forward pass
67  std::vector<int> fBackwardIndices; ///< Vector of indices used for a fast Im2Col in backward pass
68 
69 
70  EActivationFunction fF; ///< Activation function of the layer.
71  ERegularization fReg; ///< The regularization method.
72  Scalar_t fWeightDecay; ///< The weight decay.
73 
74 public:
75  /*! Constructor. */
76  TConvLayer(size_t BatchSize, size_t InputDepth, size_t InputHeight, size_t InputWidth, size_t Depth, size_t Height,
77  size_t Width, size_t WeightsNRows, size_t WeightsNCols, size_t BiasesNRows, size_t BiasesNCols,
78  size_t OutputNSlices, size_t OutputNRows, size_t OutputNCols, EInitialization Init, size_t FilterDepth,
79  size_t FilterHeight, size_t FilterWidth, size_t StrideRows, size_t StrideCols, size_t PaddingHeight,
80  size_t PaddingWidth, Scalar_t DropoutProbability, EActivationFunction f, ERegularization Reg,
81  Scalar_t WeightDecay);
82 
83  /*! Copy the conv layer provided as a pointer */
85 
86  /*! Copy constructor. */
87  TConvLayer(const TConvLayer &);
88 
89  /*! Destructor. */
90  ~TConvLayer();
91 
92  /*! Computes activation of the layer for the given input. The input
93  * must be in 3D tensor form with the different matrices corresponding to
94  * different events in the batch. Computes activations as well as
95  * the first partial derivative of the activation function at those
96  * activations. */
97  void Forward(std::vector<Matrix_t> &input, bool applyDropout = false);
98 
99  /*! Compute weight, bias and activation gradients. Uses the precomputed
100  * first partial derviatives of the activation function computed during
101  * forward propagation and modifies them. Must only be called directly
102  * at the corresponding call to Forward(...). */
103  void Backward(std::vector<Matrix_t> &gradients_backward, const std::vector<Matrix_t> &activations_backward,
104  std::vector<Matrix_t> &inp1, std::vector<Matrix_t> &inp2);
105 
106  /*! Prints the info about the layer. */
107  void Print() const;
108 
109  /*! Writes the information and the weights about the layer in an XML node. */
110  virtual void AddWeightsXMLTo(void *parent);
111 
112  /*! Read the information and the weights about the layer from XML node. */
113  virtual void ReadWeightsFromXML(void *parent);
114 
115  /*! Getters */
116  size_t GetFilterDepth() const { return fFilterDepth; }
117  size_t GetFilterHeight() const { return fFilterHeight; }
118  size_t GetFilterWidth() const { return fFilterWidth; }
119 
120  size_t GetStrideRows() const { return fStrideRows; }
121  size_t GetStrideCols() const { return fStrideCols; }
122 
123  size_t GetPaddingHeight() const { return fPaddingHeight; }
124  size_t GetPaddingWidth() const { return fPaddingWidth; }
125 
126  size_t GetNLocalViewPixels() const { return fNLocalViewPixels; }
127  size_t GetNLocalViews() const { return fNLocalViews; }
128 
130 
131  const std::vector<Matrix_t> &GetDerivatives() const { return fDerivatives; }
132  std::vector<Matrix_t> &GetDerivatives() { return fDerivatives; }
133 
134  Matrix_t &GetDerivativesAt(size_t i) { return fDerivatives[i]; }
135  const Matrix_t &GetDerivativesAt(size_t i) const { return fDerivatives[i]; }
136 
140 };
141 
142 //
143 //
144 // Conv Layer Class - Implementation
145 //______________________________________________________________________________
146 template <typename Architecture_t>
147 TConvLayer<Architecture_t>::TConvLayer(size_t batchSize, size_t inputDepth, size_t inputHeight, size_t inputWidth,
148  size_t depth, size_t height, size_t width, size_t weightsNRows,
149  size_t weightsNCols, size_t biasesNRows, size_t biasesNCols,
150  size_t outputNSlices, size_t outputNRows, size_t outputNCols,
151  EInitialization init, size_t filterDepth, size_t filterHeight,
152  size_t filterWidth, size_t strideRows, size_t strideCols, size_t paddingHeight,
153  size_t paddingWidth, Scalar_t dropoutProbability, EActivationFunction f,
155  : VGeneralLayer<Architecture_t>(batchSize, inputDepth, inputHeight, inputWidth, depth, height, width, 1,
156  weightsNRows, weightsNCols, 1, biasesNRows, biasesNCols, outputNSlices, outputNRows,
157  outputNCols, init),
158  fFilterDepth(filterDepth), fFilterHeight(filterHeight), fFilterWidth(filterWidth), fStrideRows(strideRows),
159  fStrideCols(strideCols), fPaddingHeight(paddingHeight), fPaddingWidth(paddingWidth),
160  fNLocalViewPixels(filterDepth * filterHeight * filterWidth), fNLocalViews(height * width),
161  fDropoutProbability(dropoutProbability), fDerivatives(), fF(f), fReg(reg), fWeightDecay(weightDecay)
162 {
163  for (size_t i = 0; i < outputNSlices; i++) {
164  fDerivatives.emplace_back(outputNRows, outputNCols);
165  }
166 }
167 
168 //______________________________________________________________________________
169 template <typename Architecture_t>
171  : VGeneralLayer<Architecture_t>(layer), fFilterDepth(layer->GetFilterDepth()),
173  fStrideRows(layer->GetStrideRows()), fStrideCols(layer->GetStrideCols()),
178 {
179  size_t outputNSlices = (layer->GetDerivatives()).size();
180  size_t outputNRows = 0;
181  size_t outputNCols = 0;
182 
183  for (size_t i = 0; i < outputNSlices; i++) {
184  outputNRows = (layer->GetDerivativesAt(i)).GetNrows();
185  outputNCols = (layer->GetDerivativesAt(i)).GetNcols();
186 
187  fDerivatives.emplace_back(outputNRows, outputNCols);
188  }
189 }
190 
191 //______________________________________________________________________________
192 template <typename Architecture_t>
194  : VGeneralLayer<Architecture_t>(convLayer), fFilterDepth(convLayer.fFilterDepth),
195  fFilterHeight(convLayer.fFilterHeight), fFilterWidth(convLayer.fFilterWidth), fStrideRows(convLayer.fStrideRows),
196  fStrideCols(convLayer.fStrideCols), fPaddingHeight(convLayer.fPaddingHeight),
198  fNLocalViews(convLayer.fNLocalViews), fDropoutProbability(convLayer.fDropoutProbability), fF(convLayer.fF),
199  fReg(convLayer.fReg), fWeightDecay(convLayer.fWeightDecay)
200 {
201  size_t outputNSlices = convLayer.fDerivatives.size();
202  size_t outputNRows = convLayer.GetDerivativesAt(0).GetNrows();
203  size_t outputNCols = convLayer.GetDerivativesAt(0).GetNcols();
204 
205  for (size_t i = 0; i < outputNSlices; i++) {
206  fDerivatives.emplace_back(outputNRows, outputNCols);
207  }
208 }
209 
210 //______________________________________________________________________________
211 template <typename Architecture_t>
213 {
214 }
215 
216 //______________________________________________________________________________
217 template <typename Architecture_t>
218 auto TConvLayer<Architecture_t>::Forward(std::vector<Matrix_t> &input, bool applyDropout) -> void
219 {
220 
221  fForwardIndices.resize(this->GetNLocalViews() * this->GetNLocalViewPixels() );
222 
223  R__ASSERT( input.size() > 0);
224  Architecture_t::Im2colIndices(fForwardIndices, input[0], this->GetNLocalViews(), this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(),
225  this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(),
226  this->GetPaddingHeight(), this->GetPaddingWidth());
227 
228 
229  Architecture_t::ConvLayerForward(this->GetOutput(), this->GetDerivatives(), input, this->GetWeightsAt(0), this->GetBiasesAt(0),
231  this->GetDropoutProbability(), applyDropout );
232 
233 #if 0
234  // in printciple I could make the indices data member of the class
235  Matrix_t inputTr(this->GetNLocalViews(), this->GetNLocalViewPixels());
236  //Matrix_t inputTr2(this->GetNLocalViews(), this->GetNLocalViewPixels());
237  std::vector<int> vIndices(inputTr.GetNrows() * inputTr.GetNcols() );
238  R__ASSERT( input.size() > 0);
239  Architecture_t::Im2colIndices(vIndices, input[0], this->GetNLocalViews(), this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(),
240  this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(),
241  this->GetPaddingHeight(), this->GetPaddingWidth());
242  // batch size loop
243  for (size_t i = 0; i < this->GetBatchSize(); i++) {
244 
245  if (applyDropout && (this->GetDropoutProbability() != 1.0)) {
246  Architecture_t::Dropout(input[i], this->GetDropoutProbability());
247  }
248 
249  inputTr.Zero();
250  //inputTr2.Zero();
251  // Architecture_t::Im2col(inputTr2, input[i], this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(),
252  // this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(),
253  // this->GetPaddingHeight(), this->GetPaddingWidth());
254  Architecture_t::Im2colFast(inputTr, input[i], vIndices);
255  // bool diff = false;
256  // for (int j = 0; j < inputTr.GetNrows(); ++j) {
257  // for (int k = 0; k < inputTr.GetNcols(); ++k) {
258  // if ( inputTr2(j,k) != inputTr(j,k) ) {
259  // diff = true;
260  // std::cout << "different im2col for " << j << " , " << k << " " << inputTr(j,k) << " shoud be " << inputTr2(j,k) << std::endl;
261  // }
262  // }
263  // }
264  // if (diff) {
265  // std::cout << "ConvLayer:: Different Im2Col for batch " << i << std::endl;
266  // printf("Layer parameters : %d x %d , filter %d x %d , stride %d %d , pad %d %d \n",this->GetInputHeight(), this->GetInputWidth(), this->GetFilterHeight(),
267  // this->GetFilterWidth(), this->GetStrideRows(), this->GetStrideCols(),
268  // this->GetPaddingHeight(), this->GetPaddingWidth() );
269  // // PrintMatrix(inputTr);
270  // //PrintMatrix(inputTr2);
271  // }
272  // R__ASSERT(!diff);
273  Architecture_t::MultiplyTranspose(this->GetOutputAt(i), this->GetWeightsAt(0), inputTr);
274  Architecture_t::AddConvBiases(this->GetOutputAt(i), this->GetBiasesAt(0));
275 
276  evaluateDerivative<Architecture_t>(this->GetDerivativesAt(i), fF, this->GetOutputAt(i));
277  evaluate<Architecture_t>(this->GetOutputAt(i), fF);
278  }
279 #endif
280 }
281 
282 //______________________________________________________________________________
283 template <typename Architecture_t>
284 auto TConvLayer<Architecture_t>::Backward(std::vector<Matrix_t> &gradients_backward,
285  const std::vector<Matrix_t> &activations_backward,
286  std::vector<Matrix_t> & /*inp1*/, std::vector<Matrix_t> &
287  /*inp2*/) -> void
288 {
289  Architecture_t::ConvLayerBackward(
290  gradients_backward, this->GetWeightGradientsAt(0), this->GetBiasGradientsAt(0), this->GetDerivatives(),
291  this->GetActivationGradients(), this->GetWeightsAt(0), activations_backward, this->GetBatchSize(),
292  this->GetInputHeight(), this->GetInputWidth(), this->GetDepth(), this->GetHeight(), this->GetWidth(),
293  this->GetFilterDepth(), this->GetFilterHeight(), this->GetFilterWidth(), this->GetNLocalViews());
294 
295  addRegularizationGradients<Architecture_t>(this->GetWeightGradientsAt(0), this->GetWeightsAt(0),
296  this->GetWeightDecay(), this->GetRegularization());
297 }
298 
299 //______________________________________________________________________________
300 template <typename Architecture_t>
302 {
303  std::cout << " CONV LAYER: \t";
304  std::cout << "( W = " << this->GetWidth() << " , ";
305  std::cout << " H = " << this->GetHeight() << " , ";
306  std::cout << " D = " << this->GetDepth() << " ) ";
307 
308  std::cout << "\t Filter ( W = " << this->GetFilterWidth() << " , ";
309  std::cout << " H = " << this->GetFilterHeight() << " ) ";
310  //std::cout << "\t Local Views = " << this->GetNLocalViews() << " " ;
311  if (this->GetOutput().size() > 0) {
312  std::cout << "\tOutput = ( " << this->GetOutput().size() << " , " << this->GetOutput()[0].GetNrows() << " , " << this->GetOutput()[0].GetNcols() << " ) ";
313  }
314  std::vector<std::string> activationNames = { "Identity","Relu","Sigmoid","Tanh","SymmRelu","SoftSign","Gauss" };
315  std::cout << "\t Activation Function = ";
316  std::cout << activationNames[ static_cast<int>(fF) ] << std::endl;
317 }
318 
319 //______________________________________________________________________________
320 template <typename Architecture_t>
322 {
323  auto layerxml = gTools().xmlengine().NewChild(parent, 0, "ConvLayer");
324 
325  gTools().xmlengine().NewAttr(layerxml, 0, "Depth", gTools().StringFromInt(this->GetDepth()));
326  gTools().xmlengine().NewAttr(layerxml, 0, "FilterHeight", gTools().StringFromInt(this->GetFilterHeight()));
327  gTools().xmlengine().NewAttr(layerxml, 0, "FilterWidth", gTools().StringFromInt(this->GetFilterWidth()));
328  gTools().xmlengine().NewAttr(layerxml, 0, "StrideRows", gTools().StringFromInt(this->GetStrideRows()));
329  gTools().xmlengine().NewAttr(layerxml, 0, "StrideCols", gTools().StringFromInt(this->GetStrideCols()));
330  gTools().xmlengine().NewAttr(layerxml, 0, "PaddingHeight", gTools().StringFromInt(this->GetPaddingHeight()));
331  gTools().xmlengine().NewAttr(layerxml, 0, "PaddingWidth", gTools().StringFromInt(this->GetPaddingWidth()));
332 
333 
334  int activationFunction = static_cast<int>(this -> GetActivationFunction());
335  gTools().xmlengine().NewAttr(layerxml, 0, "ActivationFunction",
336  TString::Itoa(activationFunction, 10));
337 
338  // write weights and bias matrix
339  this->WriteMatrixToXML(layerxml, "Weights", this -> GetWeightsAt(0));
340  this->WriteMatrixToXML(layerxml, "Biases", this -> GetBiasesAt(0));
341 
342 }
343 
344 //______________________________________________________________________________
345 template <typename Architecture_t>
347 {
348  // read weights and biases
349  // the meta information is read before because it is needed before creating the Conv layer
350  this->ReadMatrixXML(parent,"Weights", this -> GetWeightsAt(0));
351  this->ReadMatrixXML(parent,"Biases", this -> GetBiasesAt(0));
352 }
353 
354 
355 } // namespace CNN
356 } // namespace DNN
357 } // namespace TMVA
358 
359 #endif
size_t GetDepth() const
Definition: GeneralLayer.h:144
size_t GetInputWidth() const
Definition: GeneralLayer.h:143
size_t GetFilterWidth() const
Definition: ConvLayer.h:118
Generic General Layer class.
Definition: GeneralLayer.h:45
TXMLEngine & xmlengine()
Definition: Tools.h:270
std::vector< Matrix_t > fDerivatives
First fDerivatives of the activations of this layer.
Definition: ConvLayer.h:64
size_t fStrideRows
The number of row pixels to slid the filter each step.
Definition: ConvLayer.h:53
static TString Itoa(Int_t value, Int_t base)
Converts an Int_t to a TString with respect to the base specified (2-36).
Definition: TString.cxx:2000
size_t GetNLocalViewPixels() const
Definition: ConvLayer.h:126
size_t GetStrideRows() const
Definition: ConvLayer.h:120
size_t fFilterHeight
The height of the filter.
Definition: ConvLayer.h:50
void ReadMatrixXML(void *node, const char *name, Matrix_t &matrix)
Definition: GeneralLayer.h:502
const Matrix_t & GetBiasesAt(size_t i) const
Definition: GeneralLayer.h:158
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
Scalar_t GetDropoutProbability() const
Definition: ConvLayer.h:129
std::vector< Matrix_t > & GetDerivatives()
Definition: ConvLayer.h:132
#define R__ASSERT(e)
Definition: TError.h:96
const Matrix_t & GetDerivativesAt(size_t i) const
Definition: ConvLayer.h:135
#define f(i)
Definition: RSha256.hxx:104
~TConvLayer()
Destructor.
Definition: ConvLayer.h:212
size_t fPaddingWidth
The number of zero layers left and right of the input.
Definition: ConvLayer.h:57
size_t GetFilterDepth() const
Getters.
Definition: ConvLayer.h:116
size_t fNLocalViews
The number of local views in one image.
Definition: ConvLayer.h:60
Scalar_t GetWeightDecay() const
Definition: ConvLayer.h:139
size_t fFilterWidth
The width of the filter.
Definition: ConvLayer.h:51
UInt_t Depth(const Node< T > *node)
Definition: NodekNN.h:213
EInitialization
Definition: Functions.h:70
size_t GetStrideCols() const
Definition: ConvLayer.h:121
Matrix_t & GetOutputAt(size_t i)
Definition: GeneralLayer.h:179
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
Definition: NeuralNet.icc:496
Scalar_t fDropoutProbability
Probability that an input is active.
Definition: ConvLayer.h:62
ERegularization GetRegularization() const
Definition: ConvLayer.h:138
void Init(TClassEdit::TInterpreterLookupHelper *helper)
Definition: TClassEdit.cxx:121
size_t GetBatchSize() const
Getters.
Definition: GeneralLayer.h:140
size_t GetHeight() const
Definition: GeneralLayer.h:145
const std::vector< Matrix_t > & GetActivationGradients() const
Definition: GeneralLayer.h:176
Scalar_t fWeightDecay
The weight decay.
Definition: ConvLayer.h:72
void Forward(std::vector< Matrix_t > &input, bool applyDropout=false)
Computes activation of the layer for the given input.
Definition: ConvLayer.h:218
const Matrix_t & GetBiasGradientsAt(size_t i) const
Definition: GeneralLayer.h:170
void Print() const
Prints the info about the layer.
Definition: ConvLayer.h:301
void Backward(std::vector< Matrix_t > &gradients_backward, const std::vector< Matrix_t > &activations_backward, std::vector< Matrix_t > &inp1, std::vector< Matrix_t > &inp2)
Compute weight, bias and activation gradients.
Definition: ConvLayer.h:284
size_t GetInputHeight() const
Definition: GeneralLayer.h:142
size_t fNLocalViewPixels
The number of pixels in one local image view.
Definition: ConvLayer.h:59
size_t fPaddingHeight
The number of zero layers added top and bottom of the input.
Definition: ConvLayer.h:56
size_t GetFilterHeight() const
Definition: ConvLayer.h:117
virtual void ReadWeightsFromXML(void *parent)
Read the information and the weights about the layer from XML node.
Definition: ConvLayer.h:346
Tools & gTools()
Matrix_t & GetDerivativesAt(size_t i)
Definition: ConvLayer.h:134
TConvLayer(size_t BatchSize, size_t InputDepth, size_t InputHeight, size_t InputWidth, size_t Depth, size_t Height, size_t Width, size_t WeightsNRows, size_t WeightsNCols, size_t BiasesNRows, size_t BiasesNCols, size_t OutputNSlices, size_t OutputNRows, size_t OutputNCols, EInitialization Init, size_t FilterDepth, size_t FilterHeight, size_t FilterWidth, size_t StrideRows, size_t StrideCols, size_t PaddingHeight, size_t PaddingWidth, Scalar_t DropoutProbability, EActivationFunction f, ERegularization Reg, Scalar_t WeightDecay)
Constructor.
Definition: ConvLayer.h:147
size_t GetPaddingHeight() const
Definition: ConvLayer.h:123
const Matrix_t & GetWeightsAt(size_t i) const
Definition: GeneralLayer.h:152
size_t fStrideCols
The number of column pixels to slid the filter each step.
Definition: ConvLayer.h:54
XMLAttrPointer_t NewAttr(XMLNodePointer_t xmlnode, XMLNsPointer_t, const char *name, const char *value)
creates new attribute for xmlnode, namespaces are not supported for attributes
Definition: TXMLEngine.cxx:578
EActivationFunction GetActivationFunction() const
Definition: ConvLayer.h:137
static Int_t init()
EActivationFunction fF
Activation function of the layer.
Definition: ConvLayer.h:70
virtual void AddWeightsXMLTo(void *parent)
Writes the information and the weights about the layer in an XML node.
Definition: ConvLayer.h:321
typename Architecture_t::Scalar_t Scalar_t
Definition: ConvLayer.h:46
Abstract ClassifierFactory template that handles arbitrary types.
const std::vector< Matrix_t > & GetDerivatives() const
Definition: ConvLayer.h:131
const Matrix_t & GetWeightGradientsAt(size_t i) const
Definition: GeneralLayer.h:164
size_t GetPaddingWidth() const
Definition: ConvLayer.h:124
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
Definition: TXMLEngine.cxx:707
size_t fFilterDepth
The depth of the filter.
Definition: ConvLayer.h:49
size_t GetNLocalViews() const
Definition: ConvLayer.h:127
ERegularization
Enum representing the regularization type applied for a given layer.
Definition: Functions.h:62
void WriteMatrixToXML(void *node, const char *name, const Matrix_t &matrix)
Definition: GeneralLayer.h:479
EActivationFunction
Enum that represents layer activation functions.
Definition: Functions.h:31
const std::vector< Matrix_t > & GetOutput() const
Definition: GeneralLayer.h:173
ERegularization fReg
The regularization method.
Definition: ConvLayer.h:71
typename Architecture_t::Matrix_t Matrix_t
Definition: ConvLayer.h:45
size_t GetWidth() const
Definition: GeneralLayer.h:146
std::vector< int > fForwardIndices
Vector of indices used for a fast Im2Col in forward pass.
Definition: ConvLayer.h:66
std::vector< int > fBackwardIndices
Vector of indices used for a fast Im2Col in backward pass.
Definition: ConvLayer.h:67