PyTorch is an open-source Python library for deep learning developed by Facebook AI Research (FAIR). The installation is very simple, as instructed in Installation. TorchVision is a powerful package consists of popular datasets, model architectures, and common image transformations for computer vision.

  • PyTorch Deep Learning Model Life-Cycle

    There are five steps in building the life-cycle of a model:

    • Prepare a dataset
    • Define a model
    • Train the model
    • Make predictions
    • Evaluate the model

    1). Prepare a dataset:

    from torch.utils.data import Dataset
    from torch.utils.data import DataLoader
    from torch.utils.data import random_split
    

    Above three modules are used to load a dataset and split it into training and test parts.

    import torchvision.transforms as transforms
    

    Module “transforms” is usually used together to normalize or scale a dataset. To visualize the images (such as from CIFAR-10), you can use function “torchvision.utils.make_grid” to make a grid show of images.

    2). Define a model

    Based on your question, you define and choose a model to realize what you want.

  • The key modules in PyTorch library