Convolution layers are core components of CNNs used in image processing. They apply filters (kernels) over the input to extract important patterns and features.
Apply convolution operation using filters (kernels)
Small matrices that extract specific features from the input.
For example, one filter might detect horizontal edges while another detects vertical edges.
The values of filters are learned and updated during training.
2. Stride
Refers to the step size with which the filter moves across the input data.
Larger strides result in smaller output feature maps and faster computation.
3. Padding
Zeros or other values may be added around the input to control the spatial dimensions of the output.
Common types: "valid" (no padding) and "same" (pads output so feature map dimensions match input).
4. Activation Function
After convolution, a non-linear function like ReLU (Rectified Linear Unit) is often applied allowing the network to learn complex relationships in data.
Different types of convolution layers are used based on the task and efficiency requirements.
2D Convolution (Conv2D): Most common for images; filters move across height and width
Depthwise Separable Convolution: Reduces computation by separating depthwise and pointwise operations
Dilated (Atrous) Convolution: Expands receptive field by adding gaps in the kernel without increasing computation
Steps in a Convolution Layer
Initialize Filters: Randomly initialize a set of filters with learnable parameters.
Convolve Filters with Input: Slide the filters across the width and height of the input data, computing the dot product between the filter and the input sub-region.
Apply Activation Function: Apply a non-linear activation function to the convolved output to introduce non-linearity.
Pooling (Optional): Often followed by a pooling layer (like max pooling) to reduce the spatial dimensions of the feature map and retain the most important information.
Example Of Convolution Layer
A convolution layer transforms input data into feature maps by applying multiple filters.