22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 5.4 - Striding the image, one step at a time

The size of the movement, in pixels, is called a stride. In our

example, the stride is one.

In code, it means we’re changing the slice of the input image:

new_region = single[:, :, 0:3, (0+1):(3+1)]

But the operation remains the same: First, an element-wise multiplication, and

then adding up the elements of the resulting matrix.

Figure 5.5 - Element-wise multiplication

new_filtered_region = new_region * identity

new_total = new_filtered_region.sum()

new_total

Convolutions | 349

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!