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.

Data Generation

Our images are quite simple: They have black backgrounds and white lines drawn

on top of them. The lines can be drawn either in a diagonal or in a parallel (to one of

the edges, so they could be either horizontal or vertical) way. So, our classification

problem can be simply stated as: Is the line diagonal?

If the line is diagonal, then we assume it belongs to the positive class. If it is not

diagonal, it belongs to the negative class. We have our labels (y), which we can

summarize like this:

Line Value Class

Not Diagonal 0 Negative

Diagonal 1 Positive

Let’s generate 300 random images, each one five-by-five pixels in size:

Data Generation

1 images, labels = generate_dataset(

2 img_size=5, n_images=300, binary=True, seed=13

3 )

And then let’s visualize the first 30 images:

fig = plot_images(images, labels, n_plot=30)

Classifying Images | 267

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

Saved successfully!

Ooh no, something went wrong!