Why convolutions are everywhere
Modern deep learning architectures often include convolutions. Convolutions are optimized and efficient operations, but the reason why they are so widespread is much more profound. We are going to show that convolutions arise from simple assumptions on data.
Signals
There are many kinds of data: images, sounds, text, time series are very well-known examples. All these data are discrete. In some cases, this property is intrinsic: for example, written text is naturally a sequence of characters and words. In most cases, when data are the result of a measurement, analog signals are digitized during the acquisition process.
The devices that perform the measurements are called sensors. Sensors produce discrete signals by sampling or aggregating information from the analog world around us. For example, a sound recorder samples audio waves to register a discretized version of them. On the other hand, a camera collects photons in every pixel aggregating the light coming from all directions in a short amount of time.
From a mathematical point of view, a signal is any function defined on a discrete set. This definition is very general, and it includes all the examples above.
A discrete signal is a function whose domain is ,
.
We denote the -th value of the function as .
A very particular signal is the discrete Dirac delta.
The discrete Dirac delta is the signal .
Discrete convolution
The convolution operation is a well-known building block of deep neural networks. We are going to prove some properties of the discrete convolution. We focus our attention on the monodimensional convolution, but all theorems generalize to multiple dimensions.
Let , be two real signals, the discrete convolution of and is
The support of a function is the subset of the domain containing those elements which are not mapped to zero:
.The meaning of such a formula is not immediately understandable. It is easier to understand it through , the flipped version of .
When has finite support in ,The support of a function is the subset of the domain containing those elements which are not mapped to zero:
. we can visualize the convolution as the scalar product of with every window of elements of the signal .
In general, the summation in the convolution definition is not always finite. Recalling Holder’s inequality, we can find a sufficient condition to establish whether the convolution is well-defined for every element.
is the space of bounded sequences.
Let and be signals with such that
then is bounded.
Proof
is a bounded signal if such that
Hölder’s inequality states that if and satisfy the condition of the theorem. The special case gives the Cauchy–Schwarz inequality. Using Hölder’s inequality and with a simple change of variable, we prove the theorem:Hölder’s inequality states that if and satisfy the condition of the theorem. The special case gives the Cauchy–Schwarz inequality.
Two remarkable properties of the convolution are commutativity and linearity. These two properties are sufficient to explain why convolutions are a fundamental component of many processing systems.
Let be two real signals such that its convolution is well-defined, then
That means that the convolution is a commutative operation.
Proof
For any fixed , let , then .
Let be real signals and . If the convolutions below are all well-defined, then we have
Thus the convolution is a linear operation.
Operators
To extract information from a stream of data, we have to process it. Every operation applied to a signal is associated with an operator. For example, we can use operators to reduce noise, to recognize features, to detect peaks or discontinuities.
A discrete operator is linear if
A discrete operator is shift-invariant if
When shift-invariance holds, a shift of the signal causes a corresponding displacement of the result of the operator. For example, element-wise operations are trivially shift-invariant. The consequence is that the result of a shift-invariant operator does not depend on the absolute position of elements in a signal, only the relative position of values matters.
This new perspective shades some light on why this property is of paramount importance. Most processing operations should not depend on the absolute position of the values in the data because, in most situations, this position is arbitrary. For example, when we analyze an image, we do not want to rely on the absolute location of pixels because those positions change as soon as the image is cut or resized. The same applies to sound waves or time series.
Operators and convolution
There is a tight relationship between linear shift-invariant operators and convolution. To reveal this connection, we need to recall the discrete Dirac. Translating the discrete Dirac by , we obtain
Using this expression, we can represent every signal as a linear combination of Dirac signals
Now we have all the elements necessary to prove the main theorem of the article.
A discrete operator is linear and shift-invariant if and only if it exists a discrete signal such that for every signal
Proof
If is linear and shift-invariant, we have to prove the existence of . Setting , we have
To prove the inverse implication, we have to show that for every signal , is a linear shift-invariant operator. The linearity comes from the linearity of the convolution. Now, we show that the resulting operation is also shift-invariant.
This theorem shows that convolutions are used in many applications because there is no alternative to express linear shift-invariant operations. We have already examined why shift-invariance is frequently an essential property. While theoretical considerations implied the importance of shift-invariance, linear operators are prevalent for practical reasons. Most of the fundamental operators, like the ones associated with integration and differentiation, are linear. Furthermore, they are simple to express and very efficient on machines.
Sometimes even linearity is desired because of some characteristics of the data. Sound waves are such a type of data because they satisfy the superposition property. That means that the result of the superposition of two waves is equivalent to the sum of the single waves. In such a case, it is natural to use linear operators because linearity assures the validity of the superposition principle for the processed waves too.
Generalizations
In mathematics, a convolution is an operation defined between functions of a real variable. This continuous form is a generalization of the discrete convolution presented.
Let , be two real function, the convolution of and is
Tempered distributions are a generalization of functions. The Dirac delta is characterized by the property . No function can satisfy this property, but a tempered distribution can.All the theorems we have proved hold for the continuous case too, replacing the summation symbol with the integral sign and signals with functions or tempered distributions.Tempered distributions are a generalization of functions. The Dirac delta is characterized by the property . No function can satisfy this property, but a tempered distribution can.
Data and signals can have many dimensions: a sound wave is monodimensional; a grayscale image has two dimensions; a color image has several channels that compose the third dimension. We can define the discrete convolution for signals of arbitrary dimension and prove all the results following the same steps. This generalization extends the main theorem to all kinds of data, in particular to images where convolutions have gained their fame. We report here the definition of convolution for the general case.
Let , be two -dimensional signals, the convolution of and is
Convolutional Neural Networks
The convolution operation has become a fundamental operation in the context of deep learning, in particular in the field of computer vision. A Convolutional Neural Network (CNN) is a sequence of 3D convolutions and pooling operations. Pooling operations are non-linear, and this allows the network to learn non-linear relationships between input and output. The most common ones are max-pooling and average-pooling.
Images are a canonical example of a signal that necessitates shift-invariant operators, so it is interesting to know if CNNs are shift-invariant.
Both convolutions and pooling operations perform the same computation on all equally-sized small portions of the input signal. Such calculations are independent of the absolute location of the values, and thus, shift-invariant, at one condition. The stride of the rolling window, the difference between two consecutive positions of the window, has to be 1. A convolution with stride greater than 1 is equivalent to a classic convolution followed by a sub-sampling. The sampling picks only a specific subset of the processed signal, and this selection depends on the absolute location of values. For example, if the stride is 2, values in even or odd positions are chosen.
Currently, most successful CNNs relies on pooling operations with stride 2. Therefore they do not represent a shift-invariant operation! A researcher has noticed this flaw, and he has proposed alternative pooling operations as a replacement in the paper “Making Convolutional Networks Shift-Invariant Again”.
Conclusions
The convolution operation in machine learning does not come out-of-the-blue. It emerges naturally from simple principles and assumptions on data: linearity and shift-invariance. Machine learning often seems to progress only through empirical experiments and chance, but many foundational components have a solid theory behind. We have clarified the reason behind the extensive utilization of convolutions in many applications.