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.

soon, so please bear with me for now.

Notebook Cell 2.7

%run -i model_training/v5.py

What does the model look like after training another 200 epochs?

print(model.state_dict())

Output

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

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

Well, it didn’t change at all, which is no surprise: The original model had converged

already; that is, the loss was at a minimum. These extra epochs served an

educational purpose only; they did not improve the model. But, since we are at it,

let’s check the evolution of the losses, before and after checkpointing:

Figure 2.8 - Losses, before and after resuming training

Clearly, the loss was already at a minimum before the checkpoint, so nothing has

changed!

It turns out, the model we saved to disk was a fully trained model, so we can use it

for…

Saving and Loading Models | 167

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

Saved successfully!

Ooh no, something went wrong!