Logo ROOT   6.10/09
Reference Guide
List of all members | Public Types | List of all members
TMVA::DNN::TCpu< AReal > Class Template Reference

template<typename AReal = Real_t>
class TMVA::DNN::TCpu< AReal >

The TCpu architecture class.

Low-level interface class for multi-threaded CPU architectures. Contains as public types the declaration of the scalar, matrix and data loader types for this architecture as well as the remaining functions in the low-level interface in the form of static members.

Definition at line 37 of file Cpu.h.

Public Types

using DeviceBuffer_t = TCpuBuffer< AReal >
 
using HostBuffer_t = TCpuBuffer< AReal >
 
using Matrix_t = TCpuMatrix< AReal >
 
using Scalar_t = AReal
 

Static Public Member Functions

Forward Propagation

Low-level functions required for the forward propagation of activations through the network.

static void MultiplyTranspose (TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &input, const TCpuMatrix< Scalar_t > &weights)
 Matrix-multiply input with the transpose of and write the results into output. More...
 
static void AddRowWise (TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &biases)
 Add the vectors biases row-wise to the matrix output. More...
 
Backward Propagation

Low-level functions required for the forward propagation of activations through the network.

static void Backward (TCpuMatrix< Scalar_t > &activationGradientsBackward, TCpuMatrix< Scalar_t > &weightGradients, TCpuMatrix< Scalar_t > &biasGradients, TCpuMatrix< Scalar_t > &df, const TCpuMatrix< Scalar_t > &activationGradients, const TCpuMatrix< Scalar_t > &weights, const TCpuMatrix< Scalar_t > &activationBackward)
 Perform the complete backward propagation step. More...
 
static void ScaleAdd (TCpuMatrix< Scalar_t > &A, const TCpuMatrix< 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. More...
 
static void Copy (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
Activation Functions

For each activation function, the low-level interface contains two routines.

One that applies the acitvation function to a matrix and one that evaluate the derivatives of the activation function at the elements of a given matrix and writes the results into the result matrix.

static void IdentityDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void Relu (TCpuMatrix< Scalar_t > &B)
 
static void ReluDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void Sigmoid (TCpuMatrix< Scalar_t > &B)
 
static void SigmoidDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void Tanh (TCpuMatrix< Scalar_t > &B)
 
static void TanhDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void SymmetricRelu (TCpuMatrix< Scalar_t > &B)
 
static void SymmetricReluDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void SoftSign (TCpuMatrix< Scalar_t > &B)
 
static void SoftSignDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
static void Gauss (TCpuMatrix< Scalar_t > &B)
 
static void GaussDerivative (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 
Loss Functions

Loss functions compute a scalar value given the output of the network for a given training input and the expected network prediction Y that quantifies the quality of the prediction.

For each function also a routing that computes the gradients (suffixed by Gradients) must be provided for the starting of the backpropagation algorithm.

static Scalar_t MeanSquaredError (const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 
static void MeanSquaredErrorGradients (TCpuMatrix< Scalar_t > &dY, const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 
static Scalar_t CrossEntropy (const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the last layer in the net. More...
 
static void CrossEntropyGradients (TCpuMatrix< Scalar_t > &dY, const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 
static Scalar_t SoftmaxCrossEntropy (const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 Softmax transformation is implicitly applied, thus output should hold the linear activations of the last layer in the net. More...
 
static void SoftmaxCrossEntropyGradients (TCpuMatrix< Scalar_t > &dY, const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output)
 
Output Functions

Output functions transform the activations output of the output layer in the network to a valid prediction YHat for the desired usage of the network, e.g.

the identity function for regression or the sigmoid transformation for two-class classification.

static void Sigmoid (TCpuMatrix< Scalar_t > &YHat, const TCpuMatrix< Scalar_t > &)
 
static void Softmax (TCpuMatrix< Scalar_t > &YHat, const TCpuMatrix< Scalar_t > &)
 
Regularization

For each regularization type two functions are required, one named <Type>Regularization that evaluates the corresponding regularization functional for a given weight matrix and the Add<Type>RegularizationGradients, that adds the regularization component in the gradients to the provided matrix.

static Scalar_t L1Regularization (const TCpuMatrix< Scalar_t > &W)
 
static void AddL1RegularizationGradients (TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &W, Scalar_t weightDecay)
 
static Scalar_t L2Regularization (const TCpuMatrix< Scalar_t > &W)
 
static void AddL2RegularizationGradients (TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &W, Scalar_t weightDecay)
 
Initialization

For each initialization method, one function in the low-level interface is provided.

The naming scheme is

Initialize<Type>

for a given initialization method Type.

static void InitializeGauss (TCpuMatrix< Scalar_t > &A)
 
static void InitializeUniform (TCpuMatrix< Scalar_t > &A)
 
static void InitializeIdentity (TCpuMatrix< Scalar_t > &A)
 
static void InitializeZero (TCpuMatrix< Scalar_t > &A)
 
Dropout
static void Dropout (TCpuMatrix< Scalar_t > &A, Scalar_t p)
 Apply dropout with activation probability p to the given matrix A and scale the result by reciprocal of p. More...
 
Additional Arithmetic Functions

Additional arithmetic on CUDA matrices used to implement the low-level interface.

static void Multiply (TCpuMatrix< Scalar_t > &C, const TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &B)
 Standard multiplication of two matrices A and B with the result being written into C. More...
 
static void TransposeMultiply (TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &input, const TCpuMatrix< Scalar_t > &Weights)
 Matrix multiplication of two matrices A and B^T (transposed) with the result being written into C. More...
 
static void Hadamard (TCpuMatrix< Scalar_t > &A, const TCpuMatrix< Scalar_t > &B)
 In-place Hadamard (element-wise) product of matrices A and B with the result being written into A. More...
 
static void SumColumns (TCpuMatrix< Scalar_t > &B, const TCpuMatrix< Scalar_t > &A)
 Sum columns of (m x n) matrixx A and write the results into the first m elements in A. More...
 
static Scalar_t Sum (const TCpuMatrix< Scalar_t > &A)
 Compute the sum of all elements in A. More...
 

#include <TMVA/DNN/Architectures/Cpu.h>

Member Typedef Documentation

◆ DeviceBuffer_t

template<typename AReal = Real_t>
using TMVA::DNN::TCpu< AReal >::DeviceBuffer_t = TCpuBuffer<AReal>

Definition at line 44 of file Cpu.h.

◆ HostBuffer_t

template<typename AReal = Real_t>
using TMVA::DNN::TCpu< AReal >::HostBuffer_t = TCpuBuffer<AReal>

Definition at line 43 of file Cpu.h.

◆ Matrix_t

template<typename AReal = Real_t>
using TMVA::DNN::TCpu< AReal >::Matrix_t = TCpuMatrix<AReal>

Definition at line 42 of file Cpu.h.

◆ Scalar_t

template<typename AReal = Real_t>
using TMVA::DNN::TCpu< AReal >::Scalar_t = AReal

Definition at line 41 of file Cpu.h.

Member Function Documentation

◆ AddL1RegularizationGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::AddL1RegularizationGradients ( TCpuMatrix< Scalar_t > &  A,
const TCpuMatrix< Scalar_t > &  W,
Scalar_t  weightDecay 
)
static

Definition at line 52 of file Regularization.cxx.

◆ AddL2RegularizationGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::AddL2RegularizationGradients ( TCpuMatrix< Scalar_t > &  A,
const TCpuMatrix< Scalar_t > &  W,
Scalar_t  weightDecay 
)
static

Definition at line 98 of file Regularization.cxx.

◆ AddRowWise()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::AddRowWise ( TCpuMatrix< Scalar_t > &  output,
const TCpuMatrix< Scalar_t > &  biases 
)
static

Add the vectors biases row-wise to the matrix output.

Definition at line 50 of file Propagation.cxx.

◆ Backward()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Backward ( TCpuMatrix< Scalar_t > &  activationGradientsBackward,
TCpuMatrix< Scalar_t > &  weightGradients,
TCpuMatrix< Scalar_t > &  biasGradients,
TCpuMatrix< Scalar_t > &  df,
const TCpuMatrix< Scalar_t > &  activationGradients,
const TCpuMatrix< Scalar_t > &  weights,
const TCpuMatrix< Scalar_t > &  activationBackward 
)
static

Perform the complete backward propagation step.

If the provided activationGradientsBackward matrix is not empty, compute the gradients of the objective function with respect to the activations of the previous layer (backward direction). Also compute the weight and the bias gradients. Modifies the values in df and thus produces only a valid result, if it is applied the first time after the corresponding forward propagation has been per- formed.

Definition at line 68 of file Propagation.cxx.

◆ Copy()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::Copy ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 129 of file Arithmetic.cxx.

◆ CrossEntropy()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::CrossEntropy ( const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Sigmoid transformation is implicitly applied, thus output should hold the linear activations of the last layer in the net.

Definition at line 77 of file LossFunctions.cxx.

◆ CrossEntropyGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::CrossEntropyGradients ( TCpuMatrix< Scalar_t > &  dY,
const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Definition at line 109 of file LossFunctions.cxx.

◆ Dropout()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Dropout ( TCpuMatrix< Scalar_t > &  A,
Scalar_t  p 
)
static

Apply dropout with activation probability p to the given matrix A and scale the result by reciprocal of p.

Definition at line 24 of file Dropout.cxx.

◆ Gauss()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Gauss ( TCpuMatrix< Scalar_t > &  B)
static

Definition at line 133 of file ActivationFunctions.cxx.

◆ GaussDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::GaussDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 141 of file ActivationFunctions.cxx.

◆ Hadamard()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::Hadamard ( TCpuMatrix< Scalar_t > &  A,
const TCpuMatrix< Scalar_t > &  B 
)
static

In-place Hadamard (element-wise) product of matrices A and B with the result being written into A.

Definition at line 76 of file Arithmetic.cxx.

◆ IdentityDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::IdentityDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 27 of file ActivationFunctions.cxx.

◆ InitializeGauss()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::InitializeGauss ( TCpuMatrix< Scalar_t > &  A)
static

Definition at line 27 of file Initialization.cxx.

◆ InitializeIdentity()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::InitializeIdentity ( TCpuMatrix< Scalar_t > &  A)
static

Definition at line 65 of file Initialization.cxx.

◆ InitializeUniform()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::InitializeUniform ( TCpuMatrix< Scalar_t > &  A)
static

Definition at line 46 of file Initialization.cxx.

◆ InitializeZero()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::InitializeZero ( TCpuMatrix< Scalar_t > &  A)
static

Definition at line 84 of file Initialization.cxx.

◆ L1Regularization()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::L1Regularization ( const TCpuMatrix< Scalar_t > &  W)
static

Definition at line 26 of file Regularization.cxx.

◆ L2Regularization()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::L2Regularization ( const TCpuMatrix< Scalar_t > &  W)
static

Definition at line 72 of file Regularization.cxx.

◆ MeanSquaredError()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::MeanSquaredError ( const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Definition at line 26 of file LossFunctions.cxx.

◆ MeanSquaredErrorGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::MeanSquaredErrorGradients ( TCpuMatrix< Scalar_t > &  dY,
const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Definition at line 55 of file LossFunctions.cxx.

◆ Multiply()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::Multiply ( TCpuMatrix< Scalar_t > &  C,
const TCpuMatrix< Scalar_t > &  A,
const TCpuMatrix< Scalar_t > &  B 
)
static

Standard multiplication of two matrices A and B with the result being written into C.

Definition at line 28 of file Arithmetic.cxx.

◆ MultiplyTranspose()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::MultiplyTranspose ( TCpuMatrix< Scalar_t > &  output,
const TCpuMatrix< Scalar_t > &  input,
const TCpuMatrix< Scalar_t > &  weights 
)
static

Matrix-multiply input with the transpose of and write the results into output.

Definition at line 27 of file Propagation.cxx.

◆ Relu()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Relu ( TCpuMatrix< Scalar_t > &  B)
static

Definition at line 36 of file ActivationFunctions.cxx.

◆ ReluDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::ReluDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 44 of file ActivationFunctions.cxx.

◆ ScaleAdd()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::ScaleAdd ( TCpuMatrix< Scalar_t > &  A,
const TCpuMatrix< Scalar_t > &  B,
Scalar_t  beta = 1.0 
)
static

Adds a the elements in matrix B scaled by c to the elements in the matrix A.

This is required for the weight update in the gradient descent step.

Definition at line 114 of file Arithmetic.cxx.

◆ Sigmoid() [1/2]

template<typename AReal = Real_t>
static void TMVA::DNN::TCpu< AReal >::Sigmoid ( TCpuMatrix< Scalar_t > &  B)
static

◆ Sigmoid() [2/2]

template<typename AReal = Real_t>
static void TMVA::DNN::TCpu< AReal >::Sigmoid ( TCpuMatrix< Scalar_t > &  YHat,
const TCpuMatrix< Scalar_t > &   
)
static

◆ SigmoidDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SigmoidDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 61 of file ActivationFunctions.cxx.

◆ Softmax()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Softmax ( TCpuMatrix< Scalar_t > &  YHat,
const TCpuMatrix< Scalar_t > &   
)
static

Definition at line 33 of file OutputFunctions.cxx.

◆ SoftmaxCrossEntropy()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::SoftmaxCrossEntropy ( const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Softmax transformation is implicitly applied, thus output should hold the linear activations of the last layer in the net.

Definition at line 132 of file LossFunctions.cxx.

◆ SoftmaxCrossEntropyGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SoftmaxCrossEntropyGradients ( TCpuMatrix< Scalar_t > &  dY,
const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output 
)
static

Definition at line 171 of file LossFunctions.cxx.

◆ SoftSign()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SoftSign ( TCpuMatrix< Scalar_t > &  B)
static

Definition at line 112 of file ActivationFunctions.cxx.

◆ SoftSignDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SoftSignDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 120 of file ActivationFunctions.cxx.

◆ Sum()

template<typename AReal = Real_t>
static Scalar_t TMVA::DNN::TCpu< AReal >::Sum ( const TCpuMatrix< Scalar_t > &  A)
static

Compute the sum of all elements in A.

◆ SumColumns()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::SumColumns ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Sum columns of (m x n) matrixx A and write the results into the first m elements in A.

Definition at line 93 of file Arithmetic.cxx.

◆ SymmetricRelu()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SymmetricRelu ( TCpuMatrix< Scalar_t > &  B)
static

Definition at line 93 of file ActivationFunctions.cxx.

◆ SymmetricReluDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::SymmetricReluDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 101 of file ActivationFunctions.cxx.

◆ Tanh()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Tanh ( TCpuMatrix< Scalar_t > &  B)
static

Definition at line 73 of file ActivationFunctions.cxx.

◆ TanhDerivative()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::TanhDerivative ( TCpuMatrix< Scalar_t > &  B,
const TCpuMatrix< Scalar_t > &  A 
)
static

Definition at line 81 of file ActivationFunctions.cxx.

◆ TransposeMultiply()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< Real_t >::TransposeMultiply ( TCpuMatrix< Scalar_t > &  output,
const TCpuMatrix< Scalar_t > &  input,
const TCpuMatrix< Scalar_t > &  Weights 
)
static

Matrix multiplication of two matrices A and B^T (transposed) with the result being written into C.

Definition at line 52 of file Arithmetic.cxx.


The documentation for this class was generated from the following files: