22.02.2024 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• second block: produces 16-channel 5x5 pixels

• third block: produces 120-channel single pixel (1x1)

Then, these 120 values (or features) are flattened and fed to a typical hidden layer

with 84 units. The last step is, obviously, the output layer, which produces ten

logits to be used for digit classification (from 0 to 9, there are ten classes).

"Wait, we haven’t seen any of those multiclass classification problems

yet!"

You’re right, it is about time. But we’re still not using MNIST for this.

A Multiclass Classification Problem

A problem is considered a multiclass classification problem if there are more than

two classes. So, let’s keep it as simple as possible and build a model to classify

images into three classes.

Data Generation

Our images are going to have either a diagonal or a parallel line, BUT this time we

will make a distinction between a diagonal line tilted to the right, a diagonal line

tilted to the left, and a parallel line (it doesn’t matter if it is horizontal or vertical).

We can summarize the labels (y) like this:

Line

Label / Class Index

Parallel (Horizontal OR Vertical) 0

Diagonal, Tilted to the Right 1

Diagonal, Tilted to the Left 2

Also, let’s generate more and larger images: one thousand images, each one tenby-ten

pixels in size.

Data Generation

1 images, labels = generate_dataset(

2 img_size=10, n_images=1000, binary=False, seed=17

3 )

A Multiclass Classification Problem | 371

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

Saved successfully!

Ooh no, something went wrong!