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.

Chapter 3

A Simple Classification Problem

Spoilers

In this chapter, we will:

• build a model for binary classification

• understand the concept of logits and how it is related to probabilities

• use binary cross-entropy loss to train a model

• use the loss function to handle imbalanced datasets

• understand the concepts of decision boundary and separability

• learn how the choice of a classification threshold impacts evaluation metrics

• build ROC and precision-recall curves

Jupyter Notebook

The Jupyter notebook corresponding to Chapter 3 [68] is part of the official Deep

Learning with PyTorch Step-by-Step repository on GitHub. You can also run it

directly in Google Colab [69] .

If you’re using a local installation, open your terminal or Anaconda prompt and

navigate to the PyTorchStepByStep folder you cloned from GitHub. Then, activate

the pytorchbook environment and run jupyter notebook:

$ conda activate pytorchbook

(pytorchbook)$ jupyter notebook

If you’re using Jupyter’s default settings, this link should open Chapter 3’s

notebook. If not, just click on Chapter03.ipynb on your Jupyter’s home page.

Imports

For the sake of organization, all libraries needed throughout the code used in any

given chapter are imported at its very beginning. For this chapter, we’ll need the

following imports:

206 | Chapter 3: A Simple Classification Problem

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

Saved successfully!

Ooh no, something went wrong!