Convolutional layers in Theano
Now that we have the intuition of how convolutional layers work, we are going to implement a simple example of a convolutional layer using Theano.
Let us start by importing the modules that are needed:
import numpy import theano import matplotlib.pyplot as plt import theano.tensor as T from theano.tensor.nnet import conv import skimage.data import matplotlib.cm as cm
Theano works by first creating a symbolic representation of the operations we define. We will later have another example using Keras, that, while it provides a nice interface to make creating neural networks easier, it lacks some of the flexibility one can have by using Theano (or TensorFlow) directly.
We define the variables needed and the neural network operations, by defining the number of feature maps (the depth of the convolutional layer) and the size of the filter, then we symbolically define the input using the Theano tensor class. Theano treats the image channels as a separate dimension...