The forward two-dimensional (2D) convolution layer applies a set of nKernels 2D kernels K of size m 3 x m 4 to the input tensor X. The library supports four-dimensional input tensors XR n 1 x n 2 x n 3 x n 4 . Therefore, the following formula applies:

where i + u < n 3, j + v < n 4, and r is the kernel index.

For more details, see Forward 2D Convolution Layer.

The backward 2D convolution layer computes the derivatives of the objective function E:

Problem Statement

Without loss of generality, let's assume that convolution kernels are applied to the last two dimensions.


  • Four-dimensional tensor GR n 1 x nKernels x l 3 x l 4 with the gradient from the preceding layer

  • Four-dimensional tensor KR nKernels x m 2 x m 3 x m 4 with kernel parameters/weights of kernels (convolutions)

For the above tensors:

  • and p i is the respective padding.

  • nGroups is defined as follows: let's assume that n 2 is the group dimension in the input tensor for the forward 2D convolution layer. The output gradient tensor is split along this dimension into nGroups groups, and the input gradient tensor and weights tensor are split into nGroups groups along the nKernels dimension. nKernels and n 2 must be multiples of nGroups.

The problem is to compute:

  • Four-dimensional tensor ZR n 1 x n 2 x n 3 x n 4 such that:

  • Values:

In the above formulas:

  • s 3 and s 4 are strides

Para obter informações mais completas sobre otimizações do compilador, consulte nosso aviso de otimização.
Selecione a cor do botão adesivo: 
Orange (only for download buttons)