July 2017
Intermediate to advanced
360 pages
8h 26m
English
Even if we're not building a complete deep learning model, we can test how convolution works with a simple example. The input image we're using is already provided by SciPy:
from scipy.misc import face>>> img = face(gray=True)
The original picture is shown here:

We're going to apply a Laplacian filter, which emphasizes the boundary of each shape:
import numpy as np>>> kernel = np.array(>>> [[0, 1, 0],>>> [1, -4, 0],>>> [0, 1, 0]], >>> dtype=np.float32)>>> cfilter = np.zeros((3, 3, 1, 1), dtype=np.float32)>>> cfilter[:, :, 0, 0] = kernel
The kernel must be repeated twice because the TensorFlow convolution function tf.nn.conv2d ...
Read now
Unlock full access