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.

Output

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

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

Great, these are the weights of our trained model. Let’s train it a bit further.

In Chapter 2, we could only train it for another 200 epochs since the number of

epochs was hard-coded. Not anymore! Thanks to our StepByStep class, we have

the flexibility to train the model for as many epochs as we please.

But we are still missing one thing … the data! First, we need to set the data

loader(s), and then we can train our model for another, say, 50 epochs.

Notebook Cell 2.1.6

new_sbs.set_loaders(train_loader, val_loader)

new_sbs.train(n_epochs=50)

Let’s take a look at the losses:

fig = new_sbs.plot_losses()

Figure 2.1.3 - More losses!

We have loss values over 250 epochs now. The losses for the first 200 epochs were

loaded from the checkpoint, and the losses for the last 50 epochs were computed

after training was resumed. Once again, as in Chapter 2, the overall levels of the

losses didn’t change much.

Classy Pipeline | 201

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

Saved successfully!

Ooh no, something went wrong!