5 Machine Learning for IoT
307
Fig. 5.61 Stride of 2 pixels with filter size of 3
Fig. 5.62 Zero padding
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
5
3
1
5
2
3
1
7
1
3
-1
2
7
5
4
2
-2
3
3
1
1
8
2
1
stride is equal to 2, it means that we need to slide the filter by 2 pixels at a time and
so on. Figure 5.61 shows convolution would work with a stride of 2. This applies to
both horizontal sliding and vertical sliding.
5.6.5.3 Padding
As you might note, when we slide the filter, those pixels that are located on edges
are used (touched) less compared to the other pixels of the image. That implies that
we are losing some information related to those edge pixels. In addition, the size of
the output is shrinking in each step. Padding techniques are developed to address
this issue. In this technique, we pad the image by placing zeros around the image to
enable the filter to move (slide) on top and keep the size of the output equal to the
size of the input (see Fig. 5.62).
One can use the following equation to compute the size of the output based on
the size of the filter (f), stride (s), pad (p), and input size (n) [16]:
output size =
n + 2p − f
s
+ 1
×
n + 2p − f
s
+ 1
Précédent

- 313/647

Suivant