Important
Discrete convolution can be viewed as multiplication by a matrix, but the matrix has several entries constrained to be equal to other entries.
For example, for univariate () discrete convolution, each row of the matrix is constrained to be equal to the row above shifted by one element.
The Matrix Representation of 1D ‘Valid’ Discrete Convolution
Let’s consider a simple 1D signal and a kernel:
- Input Signal :
- Kernel :
A ‘valid’ convolution (implying no padding or kernel flipping) calculates the output only at positions where the kernel fully overlaps the signal:
This operation can be expressed as a single matrix multiplication () by constructing a corresponding Toeplitz matrix , as follows:
This proves how the sliding operation of convolution can be regarded as a single matrix multiplication.
Toeplitz matrix
Looking at the matrix :
it can be observed the following pattern:
- the second row is exactly the first row shifted one position to the right.
- the third row is the second shifted one position to the right.
This special structure, with constant diagonals, is precisely a Toeplitz matrix.
2D case
In case, convolution corresponds to a doubly block circulant matrix.
The underlying principle remains the same, but the matrix structure becomes more elaborate in order to manage the 2D nature of the image.
In addition to these equality constraints between elements, convolution usually corresponds to a sparse matrix (a matrix whose elements are mostly zero).
This is because the kernel is generally much smaller than the input image.
Looking again at the above Toeplitz matrix , notice how many zeros are present: this is due to the kernel ( elements) being smaller than the input ( elements).
In a real case, with an image of millions of pixels and a kernel of size , the matrix would be enormous but almost entirely filled with zeros.
Note
Any neural network algorithm that works with matrix multiplication and does not depend on specific properties of the matrix structure should work with convolution, without requiring any further changes to the neural network.
Typical convolutional neural networks do make use of further specializations in order to deal with large inputs efficiently, but these are not strictly necessary from a theoretical perspective.