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.

previous ones (6,823 parameters against 213 parameters for the last chapter’s

model). After it finishes, the computed losses should look like this:

fig = sbs_cnn2.plot_losses()

Figure 6.10 - Losses

Accuracy

We can also check the model’s accuracy for each class:

StepByStep.loader_apply(val_loader, sbs_cnn2.correct)

Output

tensor([[ 92, 124],

[106, 124],

[115, 124]])

The model got 313 out of 372 right. That’s 84.1% accuracy on the validation

set—not bad!

Regularizing Effect

Dropout layers are used for regularizing; that is, they should reduce overfitting

and improve generalization. Or so they say :-)

Let’s (empirically) verify this claim by training a model identical in every way BUT the

dropout, and compare its losses and accuracy to the original model.

440 | Chapter 6: Rock, Paper, Scissors

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

Saved successfully!

Ooh no, something went wrong!