First steps with PyTorch
In this section, we will take our first steps in using the low-level PyTorch API. After installing PyTorch, we will cover how to create tensors in PyTorch and different ways of manipulating them, such as changing their shape, data type, and so on.
Installing PyTorch
To install PyTorch, we recommend consulting the latest instructions on the official https://pytorch.org website. Below, we will outline the basic steps that will work on most systems.
Depending on how your system is set up, you can typically just use Python’s pip
installer and install PyTorch from PyPI by executing the following from your terminal:
pip install torch torchvision
This will install the latest stable version, which is 1.9.0 at the time of writing. To install the 1.9.0 version, which is guaranteed to be compatible with the following code examples, you can modify the preceding command as follows:
pip install torch==1.9.0 torchvision==0.10.0
If you...