18 #ifndef TMVA_DNN_ARCHITECTURES_CUDA 19 #define TMVA_DNN_ARCHITECTURES_CUDA 45 template<
typename AFloat = Real_t>
119 template<
typename AMatrix_t>
132 template<
typename AMatrix_t>
134 const std::vector<AMatrix_t> &
B);
314 size_t fltHeight,
size_t fltWidth,
size_t strideRows,
size_t strideCols,
size_t zeroPaddingHeight,
315 size_t zeroPaddingWidth);
318 size_t fltWidth,
size_t strideRows,
size_t strideCols,
size_t zeroPaddingHeight,
319 size_t zeroPaddingWidth) {}
326 size_t filterHeight,
size_t filterWidth,
size_t numFilters);
337 size_t nlocalViews,
size_t nlocalViewPixels,
338 Scalar_t dropoutProbability,
bool applyDropout) {}
358 size_t inputHeight,
size_t inputWidth,
size_t depth,
size_t height,
size_t width,
359 size_t filterDepth,
size_t filterHeight,
size_t filterWidth,
size_t nLocalViews);
366 size_t inputHeight,
size_t inputWidth,
size_t depth,
size_t height,
367 size_t width,
size_t filterDepth,
size_t filterHeight,
374 size_t batchSize,
size_t inputHeight,
size_t inputWidth,
size_t depth,
375 size_t height,
size_t width,
size_t filterDepth,
size_t filterHeight,
376 size_t filterWidth,
size_t nLocalViews);
381 size_t batchSize,
size_t depth,
size_t nLocalViews);
397 size_t imgHeight,
size_t imgWidth,
size_t fltHeight,
size_t fltWidth,
398 size_t strideRows,
size_t strideCols);
478 template <
typename AFloat>
479 template <
typename AMatrix_t>
490 template <
typename AFloat>
491 template <
typename AMatrix_t>
493 const std::vector<AMatrix_t> &
A)
495 for (
size_t i = 0; i <
B.size(); ++i) {
static Matrix_t & RecurrentLayerBackward(TCudaMatrix< AFloat > &state_gradients_backward, TCudaMatrix< AFloat > &input_weight_gradients, TCudaMatrix< AFloat > &state_weight_gradients, TCudaMatrix< AFloat > &bias_gradients, TCudaMatrix< AFloat > &df, const TCudaMatrix< AFloat > &state, const TCudaMatrix< AFloat > &weights_input, const TCudaMatrix< AFloat > &weights_state, const TCudaMatrix< AFloat > &input, TCudaMatrix< AFloat > &input_gradient)
Backward pass for Recurrent Networks.
static void ConvLayerForward(std::vector< TCudaMatrix< AFloat >> &output, std::vector< TCudaMatrix< AFloat >> &derivatives, const std::vector< TCudaMatrix< AFloat >> &input, const TCudaMatrix< Scalar_t > &weights, const TCudaMatrix< Scalar_t > &biases, EActivationFunction func, const std::vector< int > &vIndices, size_t nlocalViews, size_t nlocalViewPixels, Scalar_t dropoutProbability, bool applyDropout)
Forward propagation in the Convolutional layer.
static void SymmetricReluDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
static void RotateWeights(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &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 void Im2colFast(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B, const std::vector< int > &V)
static void MaxPoolLayerBackward(std::vector< TCudaMatrix< AFloat >> &activationGradientsBackward, const std::vector< TCudaMatrix< AFloat >> &activationGradients, const std::vector< TCudaMatrix< AFloat >> &indexMatrix, size_t batchSize, size_t depth, size_t nLocalViews)
Perform the complete backward propagation step in a Pooling Layer.
static void Im2colIndices(std::vector< int > &V, const TCudaMatrix< AFloat > &B, size_t nLocalViews, size_t imgHeight, size_t imgWidth, size_t fltHeight, size_t fltWidth, size_t strideRows, size_t strideCols, size_t zeroPaddingHeight, size_t zeroPaddingWidth)
static void GaussDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void MultiplyTranspose(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &input, const TCudaMatrix< AFloat > &weights)
Matrix-multiply input with the transpose of and write the results into output.
static void Softmax(TCudaMatrix< AFloat > &YHat, const TCudaMatrix< AFloat > &)
The TCuda architecture class.
static void ScaleAdd(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &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 Hadamard(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B)
In-place Hadamard (element-wise) product of matrices A and B with the result being written into A...
double beta(double x, double y)
Calculates the beta function.
static void IdentityDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void Deflatten(std::vector< TCudaMatrix< AFloat >> &A, const TCudaMatrix< AFloat > &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 Dropout(TCudaMatrix< AFloat > &A, AFloat p)
Apply dropout with activation probability p to the given matrix A and scale the result by reciprocal ...
double weightDecay(double error, ItWeight itWeight, ItWeight itWeightEnd, double factorWeightDecay, EnumRegularization eRegularization)
compute the weight decay for regularization (L1 or L2)
static void Reshape(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B)
Transform the matrix B to a matrix with different dimensions A.
static void SoftmaxCrossEntropyGradients(TCudaMatrix< AFloat > &dY, const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
static void CalculateConvActivationGradients(std::vector< TCudaMatrix< AFloat >> &activationGradientsBackward, std::vector< TCudaMatrix< AFloat >> &df, const TCudaMatrix< AFloat > &weights, size_t batchSize, size_t inputHeight, size_t inputWidth, size_t depth, size_t height, size_t width, size_t filterDepth, size_t filterHeight, size_t filterWidth)
Utility function for calculating the activation gradients of the layer before the convolutional layer...
This is the base class for the ROOT Random number generators.
static void Relu(TCudaMatrix< AFloat > &B)
static void Flatten(TCudaMatrix< AFloat > &A, const std::vector< TCudaMatrix< AFloat >> &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 AddRowWise(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &biases)
Add the vectors biases row-wise to the matrix output.
static AFloat SoftmaxCrossEntropy(const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
Softmax transformation is implicitly applied, thus output should hold the linear activations of the l...
static void SoftSignDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void Gauss(TCudaMatrix< AFloat > &B)
static void SymmetricRelu(TCudaMatrix< AFloat > &B)
static void TanhDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void Tanh(TCudaMatrix< AFloat > &B)
static void CalculateConvBiasGradients(TCudaMatrix< AFloat > &biasGradients, std::vector< TCudaMatrix< AFloat >> &df, size_t batchSize, size_t depth, size_t nLocalViews)
Utility function for calculating the bias gradients of the convolutional layer.
static void Multiply(TCudaMatrix< AFloat > &C, const TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &B)
Standard multiplication of two matrices A and B with the result being written into C...
static void CalculateConvWeightGradients(TCudaMatrix< AFloat > &weightGradients, std::vector< TCudaMatrix< AFloat >> &df, const std::vector< TCudaMatrix< AFloat >> &activations_backward, size_t batchSize, size_t inputHeight, size_t inputWidth, size_t depth, size_t height, size_t width, size_t filterDepth, size_t filterHeight, size_t filterWidth, size_t nLocalViews)
Utility function for calculating the weight gradients of the convolutional layer. ...
static void InitializeUniform(TCudaMatrix< AFloat > &A)
static void SetRandomSeed(size_t seed)
static void AddL2RegularizationGradients(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &W, AFloat weightDecay)
static TRandom * fgRandomGen
static void ConvLayerBackward(std::vector< TCudaMatrix< AFloat >> &activationGradientsBackward, TCudaMatrix< AFloat > &weightGradients, TCudaMatrix< AFloat > &biasGradients, std::vector< TCudaMatrix< AFloat >> &df, const std::vector< TCudaMatrix< AFloat >> &activationGradients, const TCudaMatrix< AFloat > &weights, const std::vector< TCudaMatrix< AFloat >> &activationBackward, size_t batchSize, size_t inputHeight, size_t inputWidth, size_t depth, size_t height, size_t width, size_t filterDepth, size_t filterHeight, size_t filterWidth, size_t nLocalViews)
Perform the complete backward propagation step in a Convolutional Layer.
static void InitializeGlorotNormal(TCudaMatrix< AFloat > &A)
static void Sigmoid(TCudaMatrix< AFloat > &B)
static AFloat L2Regularization(const TCudaMatrix< AFloat > &W)
static void Im2col(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &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 InitializeGlorotUniform(TCudaMatrix< AFloat > &A)
static void CrossEntropyGradients(TCudaMatrix< AFloat > &dY, const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
static void InitializeIdentity(TCudaMatrix< AFloat > &A)
static void ReluDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void MeanSquaredErrorGradients(TCudaMatrix< AFloat > &dY, const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
static TRandom & GetRandomGenerator()
static void CopyDiffArch(TCudaMatrix< Scalar_t > &B, const AMatrix_t &A)
static void Downsample(TCudaMatrix< AFloat > &A, TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &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 AFloat Sum(const TCudaMatrix< AFloat > &A)
Compute the sum of all elements in A.
static AFloat MeanSquaredError(const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
static void Backward(TCudaMatrix< AFloat > &activationGradientsBackward, TCudaMatrix< AFloat > &weightGradients, TCudaMatrix< AFloat > &biasGradients, TCudaMatrix< AFloat > &df, const TCudaMatrix< AFloat > &activationGradients, const TCudaMatrix< AFloat > &weights, const TCudaMatrix< AFloat > &activationBackward)
Perform the complete backward propagation step.
static void AddL1RegularizationGradients(TCudaMatrix< AFloat > &A, const TCudaMatrix< AFloat > &W, AFloat weightDecay)
static void AddConvBiases(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &biases)
Add the biases in the Convolutional Layer.
static void SigmoidDerivative(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
static void InitializeZero(TCudaMatrix< AFloat > &A)
static void SoftSign(TCudaMatrix< AFloat > &B)
Abstract ClassifierFactory template that handles arbitrary types.
static void TransposeMultiply(TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &input, const TCudaMatrix< AFloat > &Weights)
Matrix multiplication of two matrices A and B^T (transposed) with the result being written into C...
static void Identity(TCudaMatrix< AFloat > &B)
static void SumColumns(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
Sum columns of (m x n) matrixx A and write the results into the first m elements in A...
EActivationFunction
Enum that represents layer activation functions.
static void Rearrange(std::vector< TCudaMatrix< AFloat >> &out, const std::vector< TCudaMatrix< AFloat >> &in)
Rearrage data accoring to time fill B x T x D out with T x B x D matrix in.
static AFloat L1Regularization(const TCudaMatrix< AFloat > &W)
static void Copy(TCudaMatrix< AFloat > &B, const TCudaMatrix< AFloat > &A)
Copy the elements of matrix A into matrix B.
static AFloat CrossEntropy(const TCudaMatrix< AFloat > &Y, const TCudaMatrix< AFloat > &output, const TCudaMatrix< AFloat > &weights)
Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the l...
static void InitializeGauss(TCudaMatrix< AFloat > &A)