Discrete Convolution
Slides a filter over an input to detect local patterns; the core of CNNs.
Formula
Variables
Example
A 3x3 edge kernel highlights boundaries
How it works
Discrete convolution combines two sequences by reversing one of them, shifting it across the other, multiplying overlapping values, and summing the results at each position. This works because each output value measures how strongly the local neighborhood of the input matches the pattern encoded by the kernel, which is why convolution is so useful for feature detection. In machine learning, it lets a CNN reuse the same small set of weights across many locations, making pattern recognition efficient and translation-aware.
When to use it
Use discrete convolution when you need to extract local features from sampled data such as images, audio waveforms, or time-series signals. It is especially useful in CNNs, signal processing, smoothing, edge detection, and any setting where the same pattern may appear in different positions.
Worked example, step by step
Let f = [2, 1, 0] and g = [1, -1]. Using (f*g)(t)=\sum_{\tau} f(\tau)g(t-\tau), compute each output value: For t = 0: (f*g)(0) = f(0)g(0) = 2·1 = 2 For t = 1: (f*g)(1) = f(0)g(1) + f(1)g(0) = 2·(-1) + 1·1 = -2 + 1 = -1 For t = 2: (f*g)(2) = f(1)g(1) + f(2)g(0) = 1·(-1) + 0·1 = -1 + 0 = -1 For t = 3: (f*g)(3) = f(2)g(1) = 0·(-1) = 0 Final result: (f*g) = [2, -1, -1, 0]
Common mistakes to avoid
- Forgetting that one sequence is shifted relative to the other, which changes the sign/order of the kernel indexing
- Confusing convolution with cross-correlation and failing to reverse the kernel when required
- Ignoring boundary handling, which can change the output length and edge values
Did You Know?
Convolutional nets are inspired by the visual cortex, where neurons respond to local regions.
Share this formula
More in Machine Learning & AI
View allLinear Regression Model
BasicPredicts a continuous value as a weighted sum of input features plus a bias.
Gradient Descent Update
BasicIteratively moves parameters in the direction that most reduces the loss.
ReLU Activation
BasicRectified Linear Unit: outputs the input if positive, else zero.
Leaky ReLU
BasicA ReLU variant that lets a small gradient flow for negative inputs.
Tanh Activation
BasicSquashes input to the range (-1, 1); zero-centred activation.
Softmax
BasicTurns a vector of scores into a probability distribution that sums to 1.