Logo ROOT   6.14/05
Reference Guide
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Private Attributes | 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 43 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
 

Public Member Functions

template<typename AMatrix_t >
void CopyDiffArch (TCpuMatrix< Real_t > &B, const AMatrix_t &A)
 
template<typename AMatrix_t >
void CopyDiffArch (std::vector< TCpuMatrix< Real_t >> &B, const std::vector< AMatrix_t > &A)
 

Static Public Member Functions

static void ConvLayerForward (std::vector< TCpuMatrix< Scalar_t >> &output, std::vector< TCpuMatrix< Scalar_t >> &derivatives, const std::vector< TCpuMatrix< Scalar_t >> &input, const TCpuMatrix< Scalar_t > &weights, const TCpuMatrix< 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. More...
 
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 Matrix_tRecurrentLayerBackward (TCpuMatrix< Scalar_t > &state_gradients_backward, TCpuMatrix< Scalar_t > &input_weight_gradients, TCpuMatrix< Scalar_t > &state_weight_gradients, TCpuMatrix< Scalar_t > &bias_gradients, TCpuMatrix< Scalar_t > &df, const TCpuMatrix< Scalar_t > &state, const TCpuMatrix< Scalar_t > &weights_input, const TCpuMatrix< Scalar_t > &weights_state, const TCpuMatrix< Scalar_t > &input, TCpuMatrix< Scalar_t > &input_gradient)
 Backward pass for Recurrent Networks. 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)
 
template<typename AMatrix_t >
static void CopyDiffArch (TCpuMatrix< Scalar_t > &B, const AMatrix_t &A)
 
static void ScaleAdd (std::vector< TCpuMatrix< Scalar_t >> &A, const std::vector< TCpuMatrix< Scalar_t >> &B, Scalar_t beta=1.0)
 Above functions extended to vectors. More...
 
static void Copy (std::vector< TCpuMatrix< Scalar_t >> &A, const std::vector< TCpuMatrix< Scalar_t >> &B)
 
template<typename AMatrix_t >
static void CopyDiffArch (std::vector< TCpuMatrix< Scalar_t >> &A, const std::vector< AMatrix_t > &B)
 
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, const TCpuMatrix< Scalar_t > &weights)
 
static void MeanSquaredErrorGradients (TCpuMatrix< Scalar_t > &dY, const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &weights)
 
static Scalar_t CrossEntropy (const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &weights)
 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, const TCpuMatrix< Scalar_t > &weights)
 
static Scalar_t SoftmaxCrossEntropy (const TCpuMatrix< Scalar_t > &Y, const TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &weights)
 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, const TCpuMatrix< Scalar_t > &weights)
 
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)
 
static void InitializeGlorotNormal (TCpuMatrix< Scalar_t > &A)
 Truncated normal initialization (Glorot, called also Xavier normal) The values are sample with a normal distribution with stddev = sqrt(2/N_input + N_output) and values larger than 2 * stddev are discarded See Glorot & Bengio, AISTATS 2010 - http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf. More...
 
static void InitializeGlorotUniform (TCpuMatrix< Scalar_t > &A)
 Sample from a uniform distribution in range [ -lim,+lim] where lim = sqrt(6/N_in+N_out). More...
 
static TRandomGetRandomGenerator ()
 
static void SetRandomSeed (size_t seed)
 
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...
 
Forward Propagation in Convolutional Layer
static void Im2col (TCpuMatrix< AReal > &A, const TCpuMatrix< 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. More...
 
static void Im2colIndices (std::vector< int > &V, const TCpuMatrix< AReal > &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 Im2colFast (TCpuMatrix< AReal > &A, const TCpuMatrix< AReal > &B, const std::vector< int > &V)
 
static void RotateWeights (TCpuMatrix< AReal > &A, const TCpuMatrix< 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. More...
 
static void AddConvBiases (TCpuMatrix< Scalar_t > &output, const TCpuMatrix< Scalar_t > &biases)
 Add the biases in the Convolutional Layer. More...
 
Backward Propagation in Convolutional Layer
static void ConvLayerBackward (std::vector< TCpuMatrix< Scalar_t >> &activationGradientsBackward, TCpuMatrix< Scalar_t > &weightGradients, TCpuMatrix< Scalar_t > &biasGradients, std::vector< TCpuMatrix< Scalar_t >> &df, const std::vector< TCpuMatrix< Scalar_t >> &activationGradients, const TCpuMatrix< Scalar_t > &weights, const std::vector< TCpuMatrix< Scalar_t >> &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. More...
 
static void CalculateConvActivationGradients (std::vector< TCpuMatrix< Scalar_t >> &activationGradientsBackward, const std::vector< TCpuMatrix< Scalar_t >> &df, const TCpuMatrix< Scalar_t > &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. More...
 
static void CalculateConvWeightGradients (TCpuMatrix< Scalar_t > &weightGradients, const std::vector< TCpuMatrix< Scalar_t >> &df, const std::vector< TCpuMatrix< Scalar_t >> &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. More...
 
static void CalculateConvBiasGradients (TCpuMatrix< Scalar_t > &biasGradients, const std::vector< TCpuMatrix< Scalar_t >> &df, size_t batchSize, size_t depth, size_t nLocalViews)
 Utility function for calculating the bias gradients of the convolutional layer. More...
 
Forward Propagation in Max Pooling Layer
static void Downsample (TCpuMatrix< AReal > &A, TCpuMatrix< AReal > &B, const TCpuMatrix< 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 stored in matrix B. More...
 
Backward Propagation in Max Pooling Layer
static void MaxPoolLayerBackward (std::vector< TCpuMatrix< AReal >> &activationGradientsBackward, const std::vector< TCpuMatrix< AReal >> &activationGradients, const std::vector< TCpuMatrix< AReal >> &indexMatrix, size_t batchSize, size_t depth, size_t nLocalViews)
 Perform the complete backward propagation step in a Pooling Layer. More...
 
Forward and Backward Propagation in Reshape Layer
static void Reshape (TCpuMatrix< AReal > &A, const TCpuMatrix< AReal > &B)
 Transform the matrix B to a matrix with different dimensions A. More...
 
static void Flatten (TCpuMatrix< AReal > &A, const std::vector< TCpuMatrix< 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. More...
 
static void Deflatten (std::vector< TCpuMatrix< AReal >> &A, const TCpuMatrix< AReal > &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. More...
 
static void Rearrange (std::vector< TCpuMatrix< AReal >> &out, const std::vector< TCpuMatrix< AReal >> &in)
 Rearrage data accoring to time fill B x T x D out with T x B x D matrix in. 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, Scalar_t alpha=1.0, Scalar_t beta=0.)
 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, Scalar_t alpha=1.0, Scalar_t beta=0.)
 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...
 

Static Private Attributes

static TRandomfgRandomGen = nullptr
 

#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 52 of file Cpu.h.

◆ HostBuffer_t

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

Definition at line 51 of file Cpu.h.

◆ Matrix_t

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

Definition at line 50 of file Cpu.h.

◆ Scalar_t

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

Definition at line 49 of file Cpu.h.

Member Function Documentation

◆ AddConvBiases()

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

Add the biases in the Convolutional Layer.

Definition at line 263 of file Propagation.cxx.

◆ 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 60 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 79 of file Propagation.cxx.

◆ CalculateConvActivationGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::CalculateConvActivationGradients ( std::vector< TCpuMatrix< Scalar_t >> &  activationGradientsBackward,
const std::vector< TCpuMatrix< Scalar_t >> &  df,
const TCpuMatrix< Scalar_t > &  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 
)
static

Utility function for calculating the activation gradients of the layer before the convolutional layer.

Definition at line 355 of file Propagation.cxx.

◆ CalculateConvBiasGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::CalculateConvBiasGradients ( TCpuMatrix< Scalar_t > &  biasGradients,
const std::vector< TCpuMatrix< Scalar_t >> &  df,
size_t  batchSize,
size_t  depth,
size_t  nLocalViews 
)
static

Utility function for calculating the bias gradients of the convolutional layer.

Definition at line 510 of file Propagation.cxx.

◆ CalculateConvWeightGradients()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::CalculateConvWeightGradients ( TCpuMatrix< Scalar_t > &  weightGradients,
const std::vector< TCpuMatrix< Scalar_t >> &  df,
const std::vector< TCpuMatrix< Scalar_t >> &  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 
)
static

Utility function for calculating the weight gradients of the convolutional layer.

Definition at line 421 of file Propagation.cxx.

◆ ConvLayerBackward()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::ConvLayerBackward ( std::vector< TCpuMatrix< Scalar_t >> &  activationGradientsBackward,
TCpuMatrix< Scalar_t > &  weightGradients,
TCpuMatrix< Scalar_t > &  biasGradients,
std::vector< TCpuMatrix< Scalar_t >> &  df,
const std::vector< TCpuMatrix< Scalar_t >> &  activationGradients,
const TCpuMatrix< Scalar_t > &  weights,
const std::vector< TCpuMatrix< Scalar_t >> &  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 
)
static

Perform the complete backward propagation step in a Convolutional Layer.

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 322 of file Propagation.cxx.

◆ ConvLayerForward()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::ConvLayerForward ( std::vector< TCpuMatrix< Scalar_t >> &  output,
std::vector< TCpuMatrix< Scalar_t >> &  derivatives,
const std::vector< TCpuMatrix< Scalar_t >> &  input,
const TCpuMatrix< Scalar_t > &  weights,
const TCpuMatrix< Scalar_t > &  biases,
EActivationFunction  func,
const std::vector< int > &  vIndices,
size_t  nlocalViews,
size_t  nlocalViewPixels,
Scalar_t  dropoutProbability,
bool  applyDropout 
)
static

Forward propagation in the Convolutional layer.

Definition at line 283 of file Propagation.cxx.

◆ Copy() [1/2]

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

◆ Copy() [2/2]

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

◆ CopyDiffArch() [1/4]

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

◆ CopyDiffArch() [2/4]

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

◆ CopyDiffArch() [3/4]

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

Definition at line 478 of file Cpu.h.

◆ CopyDiffArch() [4/4]

template<typename AReal = Real_t>
template<typename AMatrix_t >
void TMVA::DNN::TCpu< AReal >::CopyDiffArch ( std::vector< TCpuMatrix< Real_t >> &  B,
const std::vector< AMatrix_t > &  A 
)

Definition at line 490 of file Cpu.h.

◆ CrossEntropy()

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

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

Definition at line 76 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,
const TCpuMatrix< Scalar_t > &  weights 
)
static

Definition at line 106 of file LossFunctions.cxx.

◆ Deflatten()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Deflatten ( std::vector< TCpuMatrix< AReal >> &  A,
const TCpuMatrix< AReal > &  B,
size_t  index,
size_t  nRows,
size_t  nCols 
)
static

Transforms each row of B to a matrix and stores it in the tensor B.

Definition at line 613 of file Propagation.cxx.

◆ Downsample()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Downsample ( TCpuMatrix< AReal > &  A,
TCpuMatrix< AReal > &  B,
const TCpuMatrix< AReal > &  C,
size_t  imgHeight,
size_t  imgWidth,
size_t  fltHeight,
size_t  fltWidth,
size_t  strideRows,
size_t  strideCols 
)
static

Downsample the matrix C to the matrix A, using max operation, such that the winning indices are stored in matrix B.

Definition at line 526 of file Propagation.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.

◆ Flatten()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Flatten ( TCpuMatrix< AReal > &  A,
const std::vector< TCpuMatrix< AReal >> &  B,
size_t  size,
size_t  nRows,
size_t  nCols 
)
static

Flattens the tensor B, such that each matrix, is stretched in one row, resulting with a matrix A.

Definition at line 599 of file Propagation.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.

◆ GetRandomGenerator()

template<typename AFloat >
TRandom & TMVA::DNN::TCpu< AFloat >::GetRandomGenerator ( )
static

Definition at line 35 of file Initialization.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 85 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.

◆ Im2col()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Im2col ( TCpuMatrix< AReal > &  A,
const TCpuMatrix< 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 
)
static

Transform the matrix B in local view format, suitable for convolution, and store it in matrix A.

Definition at line 99 of file Propagation.cxx.

◆ Im2colFast()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Im2colFast ( TCpuMatrix< AReal > &  A,
const TCpuMatrix< AReal > &  B,
const std::vector< int > &  V 
)
static

Definition at line 202 of file Propagation.cxx.

◆ Im2colIndices()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::Im2colIndices ( std::vector< int > &  V,
const TCpuMatrix< AReal > &  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

Definition at line 150 of file Propagation.cxx.

◆ InitializeGauss()

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

Definition at line 43 of file Initialization.cxx.

◆ InitializeGlorotNormal()

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

Truncated normal initialization (Glorot, called also Xavier normal) The values are sample with a normal distribution with stddev = sqrt(2/N_input + N_output) and values larger than 2 * stddev are discarded See Glorot & Bengio, AISTATS 2010 - http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf.

Definition at line 85 of file Initialization.cxx.

◆ InitializeGlorotUniform()

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

Sample from a uniform distribution in range [ -lim,+lim] where lim = sqrt(6/N_in+N_out).

This initialization is also called Xavier uniform see Glorot & Bengio, AISTATS 2010 - http://jmlr.org/proceedings/papers/v9/glorot10a/glorot10a.pdf

Definition at line 110 of file Initialization.cxx.

◆ InitializeIdentity()

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

Definition at line 129 of file Initialization.cxx.

◆ InitializeUniform()

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

Definition at line 62 of file Initialization.cxx.

◆ InitializeZero()

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

Definition at line 148 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.

◆ MaxPoolLayerBackward()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::MaxPoolLayerBackward ( std::vector< TCpuMatrix< AReal >> &  activationGradientsBackward,
const std::vector< TCpuMatrix< AReal >> &  activationGradients,
const std::vector< TCpuMatrix< AReal >> &  indexMatrix,
size_t  batchSize,
size_t  depth,
size_t  nLocalViews 
)
static

Perform the complete backward propagation step in a Pooling Layer.

Based on the winning idices stored in the index matrix, it just forwards the actiovation gradients to the previous layer.

Definition at line 559 of file Propagation.cxx.

◆ MeanSquaredError()

template<typename AReal = Real_t>
AFloat TMVA::DNN::TCpu< AFloat >::MeanSquaredError ( const TCpuMatrix< Scalar_t > &  Y,
const TCpuMatrix< Scalar_t > &  output,
const TCpuMatrix< Scalar_t > &  weights 
)
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,
const TCpuMatrix< Scalar_t > &  weights 
)
static

Definition at line 53 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 25 of file Propagation.cxx.

◆ Rearrange()

template<typename AReal >
void TMVA::DNN::TCpu< AReal >::Rearrange ( std::vector< TCpuMatrix< AReal >> &  out,
const std::vector< TCpuMatrix< AReal >> &  in 
)
static

Rearrage data accoring to time fill B x T x D out with T x B x D matrix in.

Definition at line 627 of file Propagation.cxx.

◆ RecurrentLayerBackward()

template<typename AReal = Real_t>
auto TMVA::DNN::TCpu< AFloat >::RecurrentLayerBackward ( TCpuMatrix< Scalar_t > &  state_gradients_backward,
TCpuMatrix< Scalar_t > &  input_weight_gradients,
TCpuMatrix< Scalar_t > &  state_weight_gradients,
TCpuMatrix< Scalar_t > &  bias_gradients,
TCpuMatrix< Scalar_t > &  df,
const TCpuMatrix< Scalar_t > &  state,
const TCpuMatrix< Scalar_t > &  weights_input,
const TCpuMatrix< Scalar_t > &  weights_state,
const TCpuMatrix< Scalar_t > &  input,
TCpuMatrix< Scalar_t > &  input_gradient 
)
static

Backward pass for Recurrent Networks.

Definition at line 28 of file RecurrentPropagation.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.

◆ Reshape()

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

Transform the matrix B to a matrix with different dimensions A.

Definition at line 584 of file Propagation.cxx.

◆ RotateWeights()

template<typename AReal = Real_t>
void TMVA::DNN::TCpu< AFloat >::RotateWeights ( TCpuMatrix< AReal > &  A,
const TCpuMatrix< AReal > &  B,
size_t  filterDepth,
size_t  filterHeight,
size_t  filterWidth,
size_t  numFilters 
)
static

Rotates the matrix B, which is representing a weights, and stores them in the matrix A.

Definition at line 247 of file Propagation.cxx.

◆ ScaleAdd() [1/2]

template<typename AReal = Real_t>
static void TMVA::DNN::TCpu< AReal >::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.

◆ ScaleAdd() [2/2]

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

Above functions extended to vectors.

◆ SetRandomSeed()

template<typename AFloat >
void TMVA::DNN::TCpu< AFloat >::SetRandomSeed ( size_t  seed)
static

Definition at line 29 of file Initialization.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,
const TCpuMatrix< Scalar_t > &  weights 
)
static

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

Definition at line 130 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,
const TCpuMatrix< Scalar_t > &  weights 
)
static

Definition at line 166 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,
Scalar_t  alpha = 1.0,
Scalar_t  beta = 0. 
)
static

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

Definition at line 115 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,
Scalar_t  alpha = 1.0,
Scalar_t  beta = 0. 
)
static

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

Definition at line 56 of file Arithmetic.cxx.

Member Data Documentation

◆ fgRandomGen

template<typename AReal = Real_t>
TRandom * TMVA::DNN::TCpu< AFloat_t >::fgRandomGen = nullptr
staticprivate

Definition at line 46 of file Cpu.h.

Libraries for TMVA::DNN::TCpu< AReal >:
[legend]

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