18 #ifndef TMVA_DNN_ARCHITECTURES_REFERENCE 19 #define TMVA_DNN_ARCHITECTURES_REFERENCE 42 template<
typename AReal>
114 template<
typename AMatrix_t>
126 template<
typename AMatrix_t>
314 size_t fltWidth,
size_t strideRows,
size_t strideCols,
size_t zeroPaddingHeight,
315 size_t zeroPaddingWidth);
317 size_t ,
size_t ,
size_t ,
size_t ,
size_t ) {
318 Fatal(
"Im2ColIndices",
"This function is not implemented for ref architectures");
321 Fatal(
"Im2ColFast",
"This function is not implemented for ref architectures");
327 size_t filterWidth,
size_t numFilters);
346 Fatal(
"ConvLayerForward",
"This function is not implemented for ref architectures");
375 size_t ,
size_t ,
size_t ,
size_t ,
size_t,
376 size_t ,
size_t ,
size_t ,
size_t ,
378 Fatal(
"ConvLayerBackward",
"This function is not implemented for ref architectures");
382 #ifdef HAVE_CNN_REFERENCE 385 static void CalculateConvActivationGradients(std::vector<
TMatrixT<AReal>> &activationGradientsBackward,
387 size_t batchSize,
size_t inputHeight,
size_t inputWidth,
size_t depth,
388 size_t height,
size_t width,
size_t filterDepth,
size_t filterHeight,
394 const std::vector<
TMatrixT<AReal>> &activationBackward,
size_t batchSize,
395 size_t inputHeight,
size_t inputWidth,
size_t depth,
size_t height,
396 size_t width,
size_t filterDepth,
size_t filterHeight,
size_t filterWidth,
402 size_t batchSize,
size_t depth,
size_t nLocalViews);
419 size_t imgWidth,
size_t fltHeight,
size_t fltWidth,
size_t strideRows,
size_t strideCols);
432 const std::vector<
TMatrixT<AReal>> &indexMatrix,
size_t batchSize,
size_t depth,
484 AReal learningRate,
size_t fBatchSize);
494 AReal corruptionLevel);
525 template <
typename AReal>
526 template <
typename AMatrix_t>
533 template <
typename AReal>
534 template <
typename AMatrix_t>
537 for (
size_t i = 0; i <
A.size(); ++i) {
static void SetRandomSeed(size_t seed)
static void MaxPoolLayerBackward(std::vector< TMatrixT< AReal >> &activationGradientsBackward, const std::vector< TMatrixT< AReal >> &activationGradients, const std::vector< TMatrixT< AReal >> &indexMatrix, size_t batchSize, size_t depth, size_t nLocalViews)
Perform the complete backward propagation step in a Max Pooling Layer.
static void InitializeGlorotUniform(TMatrixT< AReal > &A)
Sample from a uniform distribution in range [ -lim,+lim] where lim = sqrt(6/N_in+N_out).
static void TanhDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
static void IdentityDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
static void AddConvBiases(TMatrixT< AReal > &output, const TMatrixT< AReal > &biases)
Add the biases in the Convolutional Layer.
static void Im2col(TMatrixT< AReal > &A, TMatrixT< AReal > &B, size_t imgHeight, size_t imgWidth, size_t fltHeight, size_t fltWidth, size_t strideRows, size_t strideCols, size_t zeroPaddingHeight, size_t zeroPaddingWidth)
Transform the matrix B in local view format, suitable for convolution, and store it in matrix A...
static void Tanh(TMatrixT< AReal > &B)
static void ForwardLogReg(TMatrixT< AReal > &input, TMatrixT< AReal > &p, TMatrixT< AReal > &fWeights)
static void ConvLayerForward(std::vector< TMatrixT< AReal >> &, std::vector< TMatrixT< AReal >> &, const std::vector< TMatrixT< AReal >> &, const TMatrixT< AReal > &, const TMatrixT< AReal > &, EActivationFunction, const std::vector< int > &, size_t, size_t, AReal, bool)
Forward propagation in the Convolutional layer.
void Fatal(const char *location, const char *msgfmt,...)
static Matrix_t & RecurrentLayerBackward(TMatrixT< Scalar_t > &state_gradients_backward, TMatrixT< Scalar_t > &input_weight_gradients, TMatrixT< Scalar_t > &state_weight_gradients, TMatrixT< Scalar_t > &bias_gradients, TMatrixT< Scalar_t > &df, const TMatrixT< Scalar_t > &state, const TMatrixT< Scalar_t > &weights_input, const TMatrixT< Scalar_t > &weights_state, const TMatrixT< Scalar_t > &input, TMatrixT< Scalar_t > &input_gradient)
Backpropagation step for a Recurrent Neural Network.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
static void Im2colIndices(std::vector< int > &, const TMatrixT< AReal > &, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t)
static AReal SoftmaxCrossEntropy(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
Softmax transformation is implicitly applied, thus output should hold the linear activations of the l...
static void Sigmoid(TMatrixT< AReal > &B)
static AReal CrossEntropy(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the l...
static void SigmoidDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
static void SoftSign(TMatrixT< AReal > &B)
static void Identity(TMatrixT< AReal > &B)
static void SymmetricReluDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
double beta(double x, double y)
Calculates the beta function.
static void Im2colFast(TMatrixT< AReal > &, const TMatrixT< AReal > &, const std::vector< int > &)
static void AddL2RegularizationGradients(TMatrixT< AReal > &A, const TMatrixT< AReal > &W, AReal weightDecay)
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
This is the base class for the ROOT Random number generators.
static void SoftmaxAE(TMatrixT< AReal > &A)
static void Flatten(TMatrixT< AReal > &A, const std::vector< TMatrixT< AReal >> &B, size_t size, size_t nRows, size_t nCols)
Flattens the tensor B, such that each matrix, is stretched in one row, resulting with a matrix A...
static void Copy(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B)
static TRandom & GetRandomGenerator()
static void SoftmaxCrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static void ReconstructInput(TMatrixT< AReal > &compressedInput, TMatrixT< AReal > &reconstructedInput, TMatrixT< AReal > &fWeights)
static void ConvLayerBackward(std::vector< TMatrixT< AReal >> &, TMatrixT< AReal > &, TMatrixT< AReal > &, std::vector< TMatrixT< AReal >> &, const std::vector< TMatrixT< AReal >> &, const TMatrixT< AReal > &, const std::vector< TMatrixT< AReal >> &, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t, size_t)
Perform the complete backward propagation step in a Convolutional Layer.
static void Reshape(TMatrixT< AReal > &A, const TMatrixT< AReal > &B)
Transform the matrix B to a matrix with different dimensions A.
static void RotateWeights(TMatrixT< AReal > &A, const TMatrixT< AReal > &B, size_t filterDepth, size_t filterHeight, size_t filterWidth, size_t numFilters)
Rotates the matrix B, which is representing a weights, and stores them in the matrix A...
static AReal L1Regularization(const TMatrixT< AReal > &W)
static void InitializeUniform(TMatrixT< AReal > &A)
static void AddL1RegularizationGradients(TMatrixT< AReal > &A, const TMatrixT< AReal > &W, AReal weightDecay)
static void InitializeGlorotNormal(TMatrixT< AReal > &A)
Truncated normal initialization (Glorot, called also Xavier normal) The values are sample with a norm...
static void Backward(TMatrixT< Scalar_t > &activationGradientsBackward, TMatrixT< Scalar_t > &weightGradients, TMatrixT< Scalar_t > &biasGradients, TMatrixT< Scalar_t > &df, const TMatrixT< Scalar_t > &activationGradients, const TMatrixT< Scalar_t > &weights, const TMatrixT< Scalar_t > &activationBackward)
Perform the complete backward propagation step.
static void Relu(TMatrixT< AReal > &B)
static void SymmetricRelu(TMatrixT< AReal > &B)
static void InitializeZero(TMatrixT< AReal > &A)
static void Deflatten(std::vector< TMatrixT< AReal >> &A, const TMatrixT< Scalar_t > &B, size_t index, size_t nRows, size_t nCols)
Transforms each row of B to a matrix and stores it in the tensor B.
static void CorruptInput(TMatrixT< AReal > &input, TMatrixT< AReal > &corruptedInput, AReal corruptionLevel)
static AReal L2Regularization(const TMatrixT< AReal > &W)
static void ReluDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
static void AddBiases(TMatrixT< AReal > &A, const TMatrixT< AReal > &biases)
static void SumColumns(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
Sum columns of (m x n) matrixx A and write the results into the first m elements in A...
static void CrossEntropyGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static void UpdateParamsLogReg(TMatrixT< AReal > &input, TMatrixT< AReal > &output, TMatrixT< AReal > &difference, TMatrixT< AReal > &p, TMatrixT< AReal > &fWeights, TMatrixT< AReal > &fBiases, AReal learningRate, size_t fBatchSize)
static void GaussDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
static void Softmax(TMatrixT< AReal > &YHat, const TMatrixT< AReal > &)
static TRandom * fgRandomGen
static void Downsample(TMatrixT< AReal > &A, TMatrixT< AReal > &B, const TMatrixT< AReal > &C, size_t imgHeight, size_t imgWidth, size_t fltHeight, size_t fltWidth, size_t strideRows, size_t strideCols)
Downsample the matrix C to the matrix A, using max operation, such that the winning indices are store...
static void ScaleAdd(TMatrixT< Scalar_t > &A, const TMatrixT< Scalar_t > &B, Scalar_t beta=1.0)
Adds a the elements in matrix B scaled by c to the elements in the matrix A.
static void EncodeInput(TMatrixT< AReal > &input, TMatrixT< AReal > &compressedInput, TMatrixT< AReal > &Weights)
static void InitializeIdentity(TMatrixT< AReal > &A)
you should not use this method at all Int_t Int_t z
static void SoftSignDerivative(TMatrixT< AReal > &B, const TMatrixT< AReal > &A)
Abstract ClassifierFactory template that handles arbitrary types.
static void InitializeGauss(TMatrixT< AReal > &A)
EActivationFunction
Enum that represents layer activation functions.
static void CopyDiffArch(TMatrixT< Scalar_t > &A, const AMatrix_t &B)
static void Rearrange(std::vector< TMatrixT< AReal >> &out, const std::vector< TMatrixT< AReal >> &in)
Rearrage data accoring to time fill B x T x D out with T x B x D matrix in.
static void MultiplyTranspose(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &input, const TMatrixT< Scalar_t > &weights)
Matrix-multiply input with the transpose of and write the results into output.
static void MeanSquaredErrorGradients(TMatrixT< AReal > &dY, const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static void AddRowWise(TMatrixT< Scalar_t > &output, const TMatrixT< Scalar_t > &biases)
Add the vectors biases row-wise to the matrix output.
static void Gauss(TMatrixT< AReal > &B)
static AReal MeanSquaredError(const TMatrixT< AReal > &Y, const TMatrixT< AReal > &output, const TMatrixT< AReal > &weights)
static void Dropout(TMatrixT< AReal > &A, AReal dropoutProbability)
Apply dropout with activation probability p to the given matrix A and scale the result by reciprocal ...
static void UpdateParams(TMatrixT< AReal > &x, TMatrixT< AReal > &tildeX, TMatrixT< AReal > &y, TMatrixT< AReal > &z, TMatrixT< AReal > &fVBiases, TMatrixT< AReal > &fHBiases, TMatrixT< AReal > &fWeights, TMatrixT< AReal > &VBiasError, TMatrixT< AReal > &HBiasError, AReal learningRate, size_t fBatchSize)