Member-only story

Inside the Convolution: Building a Convolution Layer Using Numpy Arrays

See how different settings affect the output of the convolution layer

Carla Martins
8 min readJan 24, 2024

In my previous article, I explained what convolutions are and why they are so essential in computer vision. However, I didn’t get to work with some examples to show exactly how it happened. In the present post, I will explain how filters (kernels) go along the image data, and how the output is affected by different settings of the convolution layers such as kernel size or stride length.

For this purpose, we will use the simplest possible example. The image data will contain only one channel, and the convolution layer we will build will contain only one filter. The aim is to understand the basics!

In this article we will only need two libraries:

import numpy as np
import matplotlib.pyplot as np

We will use an image of the vowel ‘a’ in a 12x12 matrix in greyscale. To make things even simpler, the initial values of our initial image matrix are only 0…

--

--

Carla Martins
Carla Martins

Written by Carla Martins

Compulsive learner. Passionate about technology. Speaks C, R, Python, SQL, Haskell, Java and LaTeX. Interested in creating solutions.

Responses (1)