27 #ifndef TMVA_DNN_RESHAPELAYER 28 #define TMVA_DNN_RESHAPELAYER 40 template <
typename Architecture_t>
43 using Matrix_t =
typename Architecture_t::Matrix_t;
44 using Scalar_t =
typename Architecture_t::Scalar_t;
51 TReshapeLayer(
size_t BatchSize,
size_t InputDepth,
size_t InputHeight,
size_t InputWidth,
size_t Depth,
52 size_t Height,
size_t Width,
size_t OutputNSlices,
size_t OutputNRows,
size_t OutputNCols,
67 void Forward(std::vector<Matrix_t> &input,
bool applyDropout =
false);
69 void Backward(std::vector<Matrix_t> &gradients_backward,
const std::vector<Matrix_t> &activations_backward,
70 std::vector<Matrix_t> &inp1, std::vector<Matrix_t> &inp2);
92 template <
typename Architecture_t>
94 size_t depth,
size_t height,
size_t width,
size_t outputNSlices,
95 size_t outputNRows,
size_t outputNCols,
bool flattening)
96 :
VGeneralLayer<Architecture_t>(batchSize, inputDepth, inputHeight, inputWidth, depth, height, width, 0, 0, 0, 0, 0,
102 std::cout <<
"Reshape Dimensions not compatible \n" 110 template <
typename Architecture_t>
117 template <
typename Architecture_t>
125 template <
typename Architecture_t>
132 template <
typename Architecture_t>
136 size_t size = input.size();
137 size_t nRows = input[0].GetNrows();
138 size_t nCols = input[0].GetNcols();
139 Architecture_t::Flatten(this->
GetOutputAt(0), input, size, nRows, nCols);
142 Architecture_t::Reshape(this->
GetOutputAt(i), input[i]);
148 template <
typename Architecture_t>
150 const std::vector<Matrix_t> & ,
151 std::vector<Matrix_t> & , std::vector<Matrix_t> &
155 if (gradients_backward.size() == 0)
return;
157 size_t size = gradients_backward.size();
158 size_t nRows = gradients_backward[0].GetNrows();
159 size_t nCols = gradients_backward[0].GetNcols();
169 template <
typename Architecture_t>
172 std::cout <<
" RESHAPE Layer \t ";
175 std::cout <<
"\tOutput = ( " << this->
GetOutput().size() <<
" , " << this->
GetOutput()[0].GetNrows() <<
" , " << this->
GetOutput()[0].GetNcols() <<
" ) ";
177 std::cout << std::endl;
180 template <
typename Architecture_t>
195 template <
typename Architecture_t>
size_t GetInputWidth() const
bool isFlattening() const
TODO Add documentation Does this layer flatten? (necessary for DenseLayer) B x D1 x D2 –> 1 x B x (D...
Generic General Layer class.
bool fFlattening
Whather the layer is doing flattening.
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)
Backpropagates the error.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
void Forward(std::vector< Matrix_t > &input, bool applyDropout=false)
The input must be in 3D tensor form with the different matrices corresponding to different events in ...
UInt_t Depth(const Node< T > *node)
Matrix_t & GetOutputAt(size_t i)
size_t GetBatchSize() const
Getters.
typename Architecture_t::Matrix_t Matrix_t
size_t GetInputHeight() const
size_t GetInputDepth() const
Matrix_t & GetActivationGradientsAt(size_t i)
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
void Print() const
Prints the info about the layer.
~TReshapeLayer()
Destructor.
virtual void ReadWeightsFromXML(void *parent)
Read the information and the weights about the layer from XML node.
Abstract ClassifierFactory template that handles arbitrary types.
XMLNodePointer_t NewChild(XMLNodePointer_t parent, XMLNsPointer_t ns, const char *name, const char *content=0)
create new child element for parent node
typename Architecture_t::Scalar_t Scalar_t
const std::vector< Matrix_t > & GetOutput() const
virtual void AddWeightsXMLTo(void *parent)
Writes the information and the weights about the layer in an XML node.
TReshapeLayer(size_t BatchSize, size_t InputDepth, size_t InputHeight, size_t InputWidth, size_t Depth, size_t Height, size_t Width, size_t OutputNSlices, size_t OutputNRows, size_t OutputNCols, bool Flattening)
Constructor.