Convolutional layers
A convolutional layer (sometimes referred to in the literature as "filter") is a particular type of neural network that manipulates the image to highlight certain features. Before we get into the details, let's introduce a convolutional filter using some code and some examples. This will make the intuition simpler and will make understanding the theory easier. To do this we can use the keras
datasets, which makes it easy to load the data.
We will import numpy
, then the mnist
dataset, and matplotlib
to show the data:
import numpy from keras.datasets import mnist import matplotlib.pyplot as plt import matplotlib.cm as cm
Let's define our main function that takes in an integer, corresponding to the image in the mnist
dataset, and a filter, in this case we will define the blur
filter:
def main(image, im_filter): im = X_train[image]
Now we define a new image imC
, of size (im.width-2, im.height-2)
:
width = im.shape[0] height = im.shape[1] imC ...