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.

print(model.state_dict()) # remember, model == sbs.model

print(sbs.total_epochs)

Output

OrderedDict([('0.weight', tensor([[1.9414]], device='cuda:0')),

'0.bias', tensor([1.0233], device='cuda:0'))])

200

Our class sent the model to the available device (a GPU, in this case), and now the

model’s parameters are GPU tensors.

The weights of our trained model are quite close to the ones we got in Chapter 2.

They are slightly different, though, because we are now using yet another random

seed before starting the training loop. The total number of epochs was tracked by

the total_epochs attribute, as expected.

Let’s take a look at the losses:

fig = sbs.plot_losses()

Figure 2.1.2 - Losses

Again, no surprises here; what about making predictions for new, never seen

before data points?

198 | Chapter 2.1: Going Classy

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

Saved successfully!

Ooh no, something went wrong!