PyTorch#
PyTorch is a Python library for tensor computation and deep learning. It provides multidimensional arrays similar to NumPy, hardware acceleration, automatic differentiation, neural-network modules, optimization algorithms, and data-loading utilities. By the end of this chapter, you should be able to:
create and manipulate tensors;
reason about their shape, dtype, storage, and device;
record tensor operations and compute gradients with autograd;
optimize parameters using those gradients;
move computations between CPU and available accelerators.
Why PyTorch?
PyTorch integrates naturally with Python and offers an imperative interface that makes computations straightforward to inspect and debug. Its ecosystem includes libraries such as TorchVision for computer vision and domain-specific tools maintained by the wider community. Many popular deep learning frameworks, including HuggingFace Transformers, are built on top of PyTorch.
