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.

Recap

First of all, congratulations are in order: You have successfully implemented a fully

functioning model and training loop in PyTorch!

We have covered a lot of ground in this first chapter:

• implementing a linear regression in Numpy using gradient descent

• creating tensors in PyTorch, sending them to a device, and making parameters

out of them

• understanding PyTorch’s main feature, autograd, to perform automatic

differentiation using its associated properties and methods, like backward(),

grad, zero_(), and no_grad()

• visualizing the dynamic computation graph associated with a sequence of

operations

• creating an optimizer to simultaneously update multiple parameters, using its

step() and zero_grad() methods

• creating a loss function using PyTorch’s corresponding higher-order function

(more on that topic in the next chapter)

• understanding PyTorch’s Module class and creating your own models,

implementing __init__() and forward() methods, and making use of its builtin

parameters() and state_dict() methods

• transforming the original Numpy implementation into a PyTorch one using the

elements above

• realizing the importance of including model.train() inside the training loop

(never forget that!)

• implementing nested and sequential models using PyTorch’s layers

• putting it all together into neatly organized code divided into three distinct

parts: data preparation, model configuration, and model training

You are now ready for the next chapter. We’ll see more of PyTorch’s capabilities,

and we’ll further develop our training loop so it can be used for different problems

and models. You’ll be building your own, small draft of a library for training deep

learning models.

[39] https://github.com/dvgodoy/PyTorchStepByStep/blob/master/Chapter01.ipynb

[40] https://colab.research.google.com/github/dvgodoy/PyTorchStepByStep/blob/master/Chapter01.ipynb

Recap | 121

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

Saved successfully!

Ooh no, something went wrong!