PyTorch Advanced API Usage Guide

Author: Zen and the Art of Computer Programming

1 Introduction

PyTorch is an open source machine learning framework based on the Python language, developed and open sourced by the Facebook AI Research team. PyTorch was originally developed as a deep learning framework, but with more and more application requirements, its functions have gradually expanded, and it has become a tool for research and production use in the field of deep learning. Therefore, more and more people are beginning to use it for practical business scenarios. This article will take PyTorch's advanced API as the starting point to comprehensively and systematically introduce commonly used modules, tools, APIs and components in PyTorch. The article is not limited to the application of high-level APIs in PyTorch, but also introduces the principles and implementation methods of some underlying modules. I hope to provide a more comprehensive understanding of PyTorch users through a series of articles, and help everyone better grasp and use the framework.

2. Basic concepts and terms

  • Dataset: A collection of data used to store training samples, each sample can be an image, text, or other types of data. In PyTorch, torch.utils.data.Dataseta class or torch.utils.data.Dataseta subclass inherited from a class is generally used to define a dataset.
  • Data Loader (DataLoader): used to obtain training data from the data set, used to control the loading order of data, batch size, etc. during training. Classes are used in PyTorch torch.utils.data.DataLoaderto define data loaders.
  • Model: A computational model based on a neural network for deep learning tasks. In PyTorch, you can use nn.Moduleclasses to define models, which contain layers of some neural networks.
  • Optimizer (Optimizer): used to update model parameters to minimize the loss function

Guess you like

Origin blog.csdn.net/universsky2015/article/details/132493434